Back

Using AND and OR to pull content by Categories

Description

When pulling content by categories sometimes you need to match categories using an AND, or an OR or sometimes a combination of both.

The example below shows different scenarios on how to do this in velocity.

Code

##Query to pull all Blogs with category: Investing OR category: Conferences selected
+structureName:Blog +(categories:investing categories:conferences)

##Query to pull all Blogs with category: Investing AND category: Conferences selected
+structureName:Blog +categories:investing +categories:conferences

##Query to pull all Blogs with category: Investing AND NOT category: Conferences selected
+structureName:Blog +categories:investing -categories:conferences

##Query to pull all Blogs with category: Investing AND (category: Conferences OR category: releaseDates) selected
+structureName:Blog +categories:investing +(categories:conferences categories:categories:releaseDates)

##Query to pull all Blogs with (category: Conferences AND category:Banking) OR (category: Investing AND category: releaseDates) selected
+structureName:Blog +( (+categories:conferences +categories:banking) (+categories:investing +categories:releaseDates) )