Flex Block Filtering Issue: (Current Taxonomy Term) AND (Specific Category ID)

Posted in: Newspaper
Post count: 9

Hello tagDiv Support Team,

I am building a generic Taxonomy Archive Template using the tagDiv Cloud Library/Composer. This template is assigned to a Custom Taxonomy (e.g., prompts) and needs to load correctly for all terms within that taxonomy (e.g., /prompts/term-A, /prompts/term-B, etc.).

My goal is to display content in two separate Flex Blocks, each filtered by the current taxonomy term AND a specific Category ID.

1. Goal (Desired Query Logic):
I need to enforce the following AND logic within each Flex Block, dynamically, without hardcoding the current Taxonomy Term ID:

Section 1 (Text Posts): Posts must belong to (Current Taxonomy Term) AND (Category ID 87).

Section 2 (Image Posts): Posts must belong to (Current Taxonomy Term) AND (Category ID 88).

2. Current Setup (Flex Block Filter Settings):
I am using a Flex Block and configuring the Filter tab as follows (for Section 1, Category ID 87):

Category filter: Taxonomy – Current (Used to inherit the current term)

Multiple terms filter: 87 (Hardcoded ID of the specific category)

Posts(cpts) must belong to all terms: Checked (Intended to force the AND logic)

3. Issue/Failure Point:
Despite setting the Posts(cpts) must belong to all terms checkbox, the Flex Block query is incorrectly executed.

Observed Result: The block is showing posts that belong to Category ID 87 but are associated with OTHER, unrelated taxonomies or terms outside of the current archive page.

Example: When viewing /prompts/term-A, the block is showing posts tagged with Category ID 87, but whose main taxonomy term is from a different, unrelated taxonomy (e.g., from the guides taxonomy or another custom taxonomy).

4. Request:
Could you please advise on the correct combination of settings within the tagDiv Flex Block or provide a precise workaround to generate a strict, generic WP_Query that enforces the dynamic (Current Taxonomy Term) AND (Specific Category ID) relationship?

If this combination is not possible via the standard UI, please provide a filter or shortcode parameter that achieves this specific tax_query requirement.

Thank you for your time and assistance!

Post count: 35449

Hi,
The settings you configured are correct. What I suspect is that the CPT might belong to multiple taxonomies, or the selected taxonomy could be a parent taxonomy. Could you please share a link where I can check the example you mentioned?
Thank you!

Post count: 9

This is one such Taxonomy page – https://stealprompt.com/industry/marketing/

I am trying to show two sections on taxonomy pages,

Section 1 – Posts which belong to both ( ‘Current Taxonomy’ and ‘Text Category’)
Section 2 – Posts which belong to both ( ‘Current Taxonomy’ and ‘Image Category’)

Category Filter Settings Screenshot:
https://jumpshare.com/s/09ehJaL6zaCzKiknStbm

Post count: 35449

Hello,
From what I see in the first section, all the cpts have the ‘text’ taxonomy with id 86 so everything works correctly here, the same in the second section which uses taxonomy 87 ‘image’. Maybe you are referring to the fact that the cpt displays a different taxonomy in the frontend? https://i.imgur.com/abFxnq3.png is based on the category display https://forum.tagdiv.com/primary-category/

Post count: 9

Hi, Thanks for your quick response,

That is not the issue,

If you check, in the first & second sections, it is showing few other posts which are not related to the current taxonomy itself. In both the sections, it is showing the correct category posts, but it is also showing other taxonomy posts also (but these are related to the category which we mentioned in ).

Please check the screenshot – https://jumpshare.com/s/B5ttQdmkmGv3p0RBfUlD

In this sample page,
First section should show – only Marketing Industry posts, within that marketing Industry taxonomy it should show Text posts

Similarly, second section should show, only Marketing Industry posts, within that marketing Industry taxonomy it should show Image posts

So, it is losing ‘Current Taxonomy’ logic in those sections, and showing all the posts related to category ‘text’ and ‘image’

Post count: 35449

Hi,

As I understand what you are saying, you mean that you want to display cpts that are part of the current taxonomy and the one set in “Multiple terms filter:” using the option Posts(cpts) must belong to all terms, unfortunately that is not how that option works. The option Posts(cpts) must belong to all terms refers strictly to the IDs set in Multiple terms filter: for example if you set 2 IDs there, the displayed articles must be part of both taxonomies – https://i.imgur.com/DKYfMua.png

Thank you!

Post count: 9

Hi Calin, sorry for the trouble.

So if we mention category id in ‘Multiple terms filter’, and select option ‘Posts(cpts) must belong to all terms’,
will it loses the logic ‘Current Taxonomy’ only ?

Because it shouldn’t have shown unrelated/other taxonomy posts right?

Post count: 9

Any luck?

Post count: 35449

Hi,
The option for ‘Posts(cpts) must belong to all terms’ refers only to those terms that are added to the ‘Multiple terms filter’. Having set the options for ‘Current Taxonomy’ and the ‘Multiple terms filter’ will result in posts that belong to at least one of the filters.
Thank you!

Post count: 9

I understand, I already tried search our complete forum, seems the AND logic is not there for us.

So it shows the posts which are related to both Current Taxonomy and category id mentioned in ‘Multiple Terms Filter’ input field with OR logic.

It would be great if we have one more input filed to achieve AND logic.

if have any other plugins as extension to achieve and compatible with our theme, please help me know. If we have any code snippets to customize, would help me,.

Post count: 35449

Hi,
I added this as a suggestion on our list, and our developers will check it.
Unfortunately I do not know a plugin that has the options you need and can be used with our theme to achieve that, but I see a popular one that you can try: https://wordpress.org/plugins/filter-everything/
Thank you!

Post count: 9

Hi All, I made a custom plugin to achieve this, and it is working fine. If you guys want to try it out, let me know, I can share it.

Post count: 35449

Hi,
I’m glad you were able to get what you needed.
Also, thank you for thinking of sharing the plugin with us.
For this, you can contact us via email at contact@tagdiv.com and provide us with the plugin/code. One of our developers will check it.
Thank you!

Post count: 29

Can you share the custom plugin code?

Viewing 14 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic.