Content by Label Macro

Add a Content by Label macro to your page to display a list of pages, blog posts or attachments that have particular labels.  

This macro is great for for collecting related pages together and filtering out content that you don't want to see. You could:

  • list of all pages that have the label 'feature-shipped' and include the word 'Blueprint'
  • list any pages with the label 'meeting-notes' that you've been mentioned in.

On this page:

Screenshot: The Content by Label macro showing all pages that contain the label "printer".

For general information about using labels in Confluence, see Add, Remove and Search for Labels.

Add this macro to your page

To add the Content by Label macro to a page:

  1. From the editor toolbar, choose Insert > Other Macros.
  2. Choose Content by Label from the Confluence content category.
  3. Enter the labels you want to use as the basis for your query.
  4. Add additional filters to further narrow your query. These filters use CQL.
  5. Choose Show to change the macro parameters. These are optional. 
  6. Choose Insert

You can then publish your page to see the macro in action. 

Screenshot: Using CQL to search for content with a particular label in two spaces in the Content by Label macro

CQL filters

CQL (Confluence Query Language) is a query language developed for Confluence, which you can use in some macros and the Confluence search. Confluence search and CQL-powered macros allow you to add filters to build up a search query, adding as many filters as you need to narrow down the search results.

Use the Add a filter link to add more filters to your query.
 

Use AND, OR, and NOT operators
  • For an OR search, specify multiple values in the same field.
    So to show pages with 'label-a', 'label-b' or both you'd put 'label-a' and 'label-b' in the same Label field, like this:
  • For an AND search, add more than one filter and specify a single value in each.
    To show only pages with label-a and label-b you'd put 'label-a' in one label field, then add a second Label field to the macro, and put 'label-b' in the second one, like this:

    Put simply, OR values are entered in the same filter, AND values are entered in different filter. 
    Only some filters support AND. If the filter doesn't support the AND operator, you won't be able to add that filter more than once.  
  • For a NOT search, enter a minus sign (-) before the label. This'll exclude everything with that label.


You can use the following CQL filters to build your query:

FilterDescriptionOperators
Label*

Include pages, blog posts or attachments with these labels.

OR (multiple values in the same filter)

AND (multiple Label filters)

With ancestor

Include pages that are children of this page.

This allows you to restrict the macro to a single page tree.

OR (multiple values in the same filter)
Contributor**

Include pages or blog posts that were created or edited by these people.

OR (multiple values in the same filter)
Creator

Include items created by these people.

OR (multiple values in the same filter)
Mentioning user

Include pages and blog posts that @mention these people.

OR (multiple values in the same filter)
With parentInclude only direct children of this page (further sub-pages won't be included)EQUALS (one page only)
In space**Include items from these spaces.OR (multiple values in the same filter)
Including text**Include items that contain this text.CONTAINS (single word or phrase)
With titleInclude items that contain this text in the title.CONTAINS (single word or phrase)
Of type**Include only pages, blogs or attachments.OR (multiple values in the same filter)

* This field is required in CQL-powered macros.

** You can add these filters in CQL-powered macros but in search they're part of the standard search filters, so they don't appear in the Add a filter menu.

Change the macro parameters

Macro parameters are used to change the behaviour of a macro.

To change the macro parameters:

  1. In the editor, click the macro placeholder and choose Edit.
  2. Update the parameters as required then choose Insert.

Here's a list of the parameters available in this macro. 

ParameterDefaultDescription
Sort byModified

Sort the list by title, the date it was created, or the date it was last modified. If you don't select an option, CQL default ordering by relevancy is used.

Reverse sortFalseSort the list descending instead of ascending (Z - A, earliest - latest)
Maximum number of pages15Limit the number of items to include in the list. This can be any value up to 500 pages.
List titleBlankInclude an optional heading for the macro
Show labels for each pageTrueShow or hide the labels applied to each item
Show space name for each pageTrueShow or hide the space name for each item
Display excerptsFalse

Allows you to include a short excerpt under each page in the list. Choose between:

  • None - no excerpt will be displayed.
  • Simple - displays the first line of text contained in an Excerpt macro any of the returned pages. If there is not an Excerpt macro on the page, nothing will be shown.
  • Rich content - displays the contents of an Excerpt macro, or if there is not an Excerpt macro on the page, the first part of the page content, as formatted text, including images and some macros.
Exclude current pageFalseAllows you to exclude the page the macro appears on from the list. This is useful when the current page contains the same labels as the pages you want to include in the list.

Where the parameter name used in Confluence storage format or wikimarkup is different to the label used in the macro browser, it will be listed below in brackets (example).

Other ways to add this macro

Add this macro as you type

Type followed by the start of the macro name, to see a list of macros. 

Add this macro using wiki markup

You can't use wiki markup to add this macro.

Last modified on Jul 27, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.