As explained, you can use Filters to determine what articles should be returned by the {articles}
Plugin Tag. The filters will determine what list of articles is output, along with the Limit and Ordering.
So for instance, you can show data from the articles in a certain category that also have a specific tag:
{articles category="Dogs" tags="Tiny"}...{/articles}
You can combine any filters to narrow down the resulting list of articles. Each filter can also have multiple values, separated with a comma.
Note that values in filters should only be separated by a comma, so no extra spaces between the values.
{articles category="Cats,Dogs" tags="Tiny,Small,Medium"}...{/articles}
Note: if you don't specify any filter, *all* articles from the website will be returned (although with a Default Limit set to 100).
You can filter articles by a huge range of data types, including categories, tags, dates, and even by custom field values - pretty much by anything you can think of. Check out the Full List of Data Types available for everything you can use in the filters.
Let’s take a look at the most common Filters available and their respective options and features:
Articles
You can simply specify a comma-separated list of articles you want to display, either by using the title, alias or ID of the articles:
{articles title="Maine Coone,Norwegian Forest Cat,Persian"}...{/articles}
{articles alias="maine-coone,norwegian-forest-cat,persian"}...{/articles}
{articles id="8,27,123"}...{/articles}
If your article title contains a comma, either simply use the article alias or ID instead, or escape the comma. For instance, if you want to show the articles "American, British and Exotic Shorthair" and "Munchkin", you can escape the comma with \
in front of the article:
{articles title="American\, British and Exotic Shorthair,Munchkin"}...{/articles}
Categories
You can display multiple articles by their category. All you need to do is to place a category="..."
attribute in the tag:
{articles category="Dogs,some-category,12"}...{/articles}
With the above tag, you can use either the title, alias or ID of the desired categories, separating multiple categories with a comma.
If you want to fine-tune your filters, you can also use the more specific attributes below:
{articles category:title="Dogs,Cats"}...{/articles}
{articles category:alias="some-category,another-cat"}...{/articles}
{articles category:id="8,12,27"}...{/articles}
To also include the articles from all child categories (subcategories of the given category), you can add a include-child-categories="true"
attribute:
{articles category="Dogs" include-child-categories="true"}...{/articles}
To include the articles from the first level of child categories (categories directly under the given category), you can add the include-child-categories="1"
attribute. And use include-child-categories="2"
to include the articles from the first and second level of child categories.
Tags
You can display multiple articles by their tags. All you need to do is place a tags="..."
attribute in the tag.
By separating tags with a comma, it will show all articles that contain ANY of the tags.
In the below example, it will show all articles that either have the Fluffy
OR the Cuddly
tag.
{articles tags="Fluffy,Cuddly"}...{/articles}
To show articles that contain ALL specified tags, you can do so by separating the tags with a &&
instead.
This will show articles that have both the Fluffy
AND the Cuddly
tags at the same time:
{articles tags="Fluffy && Cuddly"}...{/articles}
Similarly to categories, you can include articles from all child tags (children of the given tag), by adding a include-child-tags="true"
attribute:
{articles tags="Fluffy" include-child-tags="true"}...{/articles}
Authors
Want to only show articles by a certain author? Just filter down based on the author name:
{articles author="Peter"}...{/articles}
Or by the author id:
{articles author:id="42"}...{/articles}
You can even show articles written by the user currently browsing the website, by utilizing the user:id
value.
{articles author:id="user:id"}...{/articles}
You can also filter by the modifier
value to output articles last modified by a certain author.
Dates
You can filter articles based on the publish-up
, created
and modified
dates, as well as custom fields of type calendar
. You have various formats that you can use inside any of these date filters.
To return articles published at an exact Date and Time:
{articles publish-up="2019-02-15 09:30:00"}...{/articles}
To show all articles published on a specific Date (regardless of time):
{articles publish-up="2019-02-15"}...{/articles}
To filter articles by Month (for example, showing all articles published in February 2019):
{articles publish-up="2019-02"}...{/articles}
And to show all articles published in a certain Year, you can simply do:
{articles publish-up="2019"}...{/articles}
Date Ranges
You can also show articles published before or after a certain Date (Time, Month and Year formats are also possible). To do this, use the "Greater or Less than..." feature as described in the Comparison Operators section:
{articles publish-up=">2019-02-15"}...{/articles}
{articles publish-up="<2019"}...{/articles}
The date filter even supports Date Ranges. This allows you to show articles published between two specific dates (Time format is also possible):
{articles publish-up="2018-11-14 to 2018-11-28"}...{/articles}
{articles publish-up="2019-02-15 09:30:00 to 2019-02-15 18:30:00"}...{/articles}
And you can use special Relative Dates values to return and compare articles from the current day, yesterday, tomorrow, or any other date relative to today.
This, for example, allows to output all articles published yesterday. Or to output all articles published in the last 30 days:
{articles publish-up="date('yesterday')"}...{/articles}
{articles publish-up="date('-30 days') to now()"}...{/articles}
Note: All Date Filters will be adjusted correctly according to the Time Zone used on your website.
Featured
You can make Articles Anywhere output all featured articles by adding a featured
attribute:
{articles featured="true"}...{/articles}
Or exclude all featured articles:
{articles featured="false"}...{/articles}
Custom Fields
You can even filter articles by the value of the custom fields. You need to use the field name as the attribute key.
Let's say you have a custom field "Number of legs" that has a field name nr-of-legs
and you want to filter down to articles that have this value set to 3
.
{articles nr-of-legs="3"}...{/articles}
You can also filter to articles where a custom field value is greater or less than your specified value (See the Comparison Operators section for a full explanation):
{articles nr-of-legs=">3"}...{/articles}
{articles nr-of-legs="<3"}...{/articles}
Field Text J4
When filter by custom field values, the condition will check the raw value of the custom field (as saved in the database).
But in certain cases, such as lists or checkbox fields, you might want to check against the text value of the custom field instead. You can do so by adding :text
after the name of the field:
{articles nr-of-legs:text="Three legs"}...{/articles}
Reserved Field Names
If your custom field name is called the same as a reserved attribute key already used by Articles Anywhere (for example in the case of a custom field called category
or type
), you can filter by your custom field with that name by prepending the attribute with a field:
prefix:
{articles field:category="books"}...{/articles}
Or by using the field ID after the field:
prefix:
{articles field:9="books"}...{/articles}
Other Article Data
Like with the custom fields, you can also filter down to any other article data. As long as it is directly saved in the articles database (must match the column name in the database table).
So you can use filters like metakey="..."
to show articles that have the metakey field containing a certain value.
Check out the Full List of Data Types available for everything you can use in the filters.