1

I'm trying to narrow the data source in WP Visual Composer to posts that have 2 categories (cat1 and cat2).

This is the complete element (a post grid):

[vc_basic_grid post_type="post" max_items="-1" element_width="2" gap="20" item="masonryGrid_Default" grid_id="vc_gid:1531579131384-317a2fc3-f3e3-3" taxonomies="7, 4" el_class="relatedMedals"]

The interface for my theme has no options to exclude categories, or to define posts that belong to more than one.

Is there anything I can write here that would filter posts so that only those containing BOTH categories show?

from:

taxonomies="7, 4"

to:

taxonomies="(ONLY ITEMS WITH BOTH) 7 (AND) 4"
Yisela
  • 6,909
  • 5
  • 28
  • 51
  • this two are totally different. First one is an array and the second one is a string – Empty Brain Jul 14 '18 at 16:14
  • @EmptyBrain Meaning it can't be changed at all? – Yisela Jul 14 '18 at 17:46
  • Normally yes. If you to write some code you can change it. Before doing so please review copyright statement. I think `7, 4` means `(BOTH) 7 (AND) 4` as well. – Empty Brain Jul 14 '18 at 18:09
  • @EmptyBrain Thanks for replying! It means AND, but I need something that excludes other results and shows only items with both cat1 AND cat2. What it does now is pick up all items from category1 and all from category2. The site is about military medals, I want to show British medals for WW1. It's showing all British medals (for all wars), and all WW1 medals (from all countries). :/ – Yisela Jul 14 '18 at 18:51
  • Why not use shortcode? You will have alot more flexibility and it will be easier for future development. – Fresz Jul 14 '18 at 19:12

1 Answers1

0

Just in case this helps anyone, I finally used a custom query (instead of the taxonomy for posts), which supports more than one category:

category__and%5B20%5D=12&category__and%5B21%5D=4&post_status=publish

Each category being:

category__and%5B20%5D=12
Yisela
  • 6,909
  • 5
  • 28
  • 51