AND rather than OR for categories in Shortcode

Viewing 5 posts - 1 through 5 (of 5 total)
#22282

etc
Member

Using 2.7 free version.

I would like to use a shortcode to display items that match 2 categories. However, when I put “category-one,category-two” in the shortcode, separated by a comma, it treats this as an OR and returns items matching either of the two. Is there a way to make this match only those items that are in both categories?

#22310

Shahjada
Keymaster

You need to edit code at functions.php line# 741 ~ 749

#22359

etc
Member

Thank you for pointing me to the right place!

I merely had to add one line to the tax_query array to get the desired functionality.

'operator' โ–บ 'AND'

I appreciate your time and really like this plugin.

#22548

Shahjada
Keymaster

thanks, if you like the plugin, please give it a 5* rating here https://wordpress.org/support/view/plugin-reviews/download-manager?rate=5#postform ๐Ÿ™‚

#42023

etc
Member

I just found that your latest version makes $operator a variable…and I have now been able to set operator=AND in my shortcodes. No more manual edits every time I update the plugin!

Thank you for making this modification, and continued success. I use this plugin on multiple sites and it does what I need.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘AND rather than OR for categories in Shortcode’ is closed to new replies.