"Content by Label" Macro Strips Out the Minus Sign "-" When Editing
Asked by Cate Vieira:

Hi there,

I am using the Content by Label Macro, and am utilizing the  
"NOT" operator by inserting a minus sign ("-") to exclude the current page from displaying in the list. For example, I'll do up the settings and then I'll have a filter for *With title* input as **-"Title Page"** as described in [this support article](http://?https://support.atlassian.com/confluence-cloud/docs/insert-the-content-by-label-macro/#ContentbyLabelMacro-AND-OR-andNOToperators). This way, all pages with the input label(s) are displayed, except for the current page (if applicable).

This works fine.

The error comes up when I go to edit the macro, the NOT operator ("-") is already stripped out. This means the filter *With title* displays as **"Title Page"** instead of the original **-"Title Page"** which completely alters the displayed pages in the macro. Instead, it will *only* display the Title Page (the opposite of the original intention!). Usually, when going to edit the macro, it's to add or remove a label from the filter, and the *With title* filter goes untouched. However, it's really easy to miss that the NOT operator ("-") has been stripped out of the *With title* filter, and that the user needs to input it again in order to restore the original functionality.

++Solution++: Ensure the Not operator ("-") does not get stripped out when editing the macro. It should remain as is unless manually changed by the user.


Answers:
author: Shannon S
body: Hello Cate,

Thank you for raising this question on Community. In the [Content by Label](https://support.atlassian.com/confluence-cloud/docs/insert-the-content-by-label-macro/) macro, the **With title** filter uses the CONTAINS operator. So, unfortunately, you won't be able to use the NOT to exclude page titles, only to exclude specific labels.

We do have a feature request for this, but unfortunately, it's been open for a long time, and I don't expect to see this solved soon:

* [CONFCLOUD-5245](https://jira.atlassian.com/browse/CONFCLOUD-5245) *Option to exclude current page in results when using contentbylabel* macro

I hope that helps explain why this wasn't working for you, but please let me know if you have any further questions.

Take care,

Shannon

comments: author: Cate Vieira
body: Hi Shannon, the thing is that it does work! It's only when editing that the "-" gets stripped out from the field. So one has to input it again to get the NOT feature working. It's 100% working, just annoying to maintain.


author: Shannon S
body: Hi Cate,

My apologies - I overlooked that you mentioned that. I have added your findings to the feature request internally, as I don't think it's intentional, and you've found an undocumented workaround.

Feel free to add your notes to the feature request, too - that way, if anyone comes along trying to do the same, they will see your workaround.

Thanks again, and take care,

Shannon


author: Cate Vieira
body: Hi Shannon, I've tried adding my comment below multiple times, however I cannot. See attached screenshot. I have tried refreshing, logging out and in, etc. Can you please add on my behalf?![Screen Shot 2021-08-23 at 11.06.06 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/157065i53157893842164EF/image-size/large?v=v2&px=999 "Screen Shot 2021-08-23 at 11.06.06 am.png")

Hi all,

So I did find a partial workaround. You can add the filter for *With title* and input as **-"Title Page"**

It's important to add the minus sign ("-") before the Title in quotes. So if the page you want to remove is "Information About Product X" you'd input

**-"Information About Product X"** in the field.

++**Caveats**++

* If another page has those words within its title, that page will be stripped out as well. So any non-specific page isn't ideal to use with this filter. ie if you want to remove a page called "About" it will remove all pages that have "about" in the title
* It is annoying if a page title changes, since you'd need to update the filter. An "exclude current page" filter would be better for this.
* Once you've set up the macro, if you edit the macro, the filter erroneously strips out the minus sign. So in the example above, if I go to edit the macro, the filter changes from  
  **-"Information About Product X"** to  
  **"Information About Product X"** in the field. Meaning that the very page you are trying to remove is instead the *only* page that appears in the macro.
  * Therefore, every time you go to edit the macro, you need to input the minus sign manually in order to restore the intention of the filter.

This is a somewhat annoying workaround to maintain, and it does too much if the title page is a generic word in your catalogue. I would still like to have the macro updated so that the related pages by label has the option to remove the current page, or self page. As that will reduce maintenance and expand the capability of the macro.


author: Shannon S
body: Hi Cate,

Thank you for sharing your workaround! I tried to paste your workaround into the Jira case, but I get the same error. There may be a problem with the formatting or your use of the minus sign that Jira disagrees with.

You can try to simplify your reply and then link to your comment directly:

<https://community.atlassian.com/t5/Confluence-questions/Re-Re-quot-Content-by-Label-quot-Macro-Strips-Out-the-Minus-Sig/qaq-p/1783932/comment-id/215781#M215781>

You can also add the workaround as a new answer in reply to this question. I can accept your answer, so it's at the top of the page.

I hope that helps!

Shannon


author: Cate Vieira
body: How can I report this as a bug? Even just with basic text, before I even hyperlinked to the comment, it still won't allow me to comment.![Screen Shot 2021-08-24 at 11.55.42 am.png](https://community.atlassian.com/t5/image/serverpage/image-id/157244i9B96C35E9E04CE87/image-size/large?v=v2&px=999 "Screen Shot 2021-08-24 at 11.55.42 am.png")


author: Shannon S
body: Hi Cate,

Can you try again using this link?

<https://jira.atlassian.com/browse/CONFCLOUD-5245>

I pasted the link in before and it had a space at the end, so when Community served the link, it was adding the space as part of the URL:

<https://jira.atlassian.com/browse/CONFCLOUD-5245%C2%A0>

I removed the space and now the link loads properly and I no longer get that error.

Let me know how it goes.

Shannon


author: Cate Vieira
body: That worked! thanks.


author: Shannon S
body: Hi Cate,

Glad to hear it! I'm so sorry about that. I didn't expect it to interfere with Jira like that.

Take care!

Shannon


Tags: cloud

confluence-cloud