Skip Navigation

[Resolved] Views filter set by taxonomy of the page where it is displayed not working

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is the user's Views filter set by taxonomy of the page is not working.

Solution:

In this case the user had some custom code that is causing the query to not work. If there are any custom code on your site relating to taxonomy please remove it temporarily and try again.

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 19 replies, has 2 voices.

Last updated by Johan Marneweck 6 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#618989

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Johan,

To understand what you're saying is that your Taxonomy term archive here : hidden link

It's displaying posts from the different Custom Post Types that has the same categories attached to it.

Correct?

Please let me know.
Thanks,
Shane

#618997

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Johan,

I was able to fix this by adding an additional conditional that ensures that the code will run only if its an archive page.

add_action( 'pre_get_posts', 'exclude_cpt' );
function exclude_cpt( $query ) {
   if ( $query->is_tax('supplier-category') && is_archive()) {
       $query->set( 'post_type', array('supplier') );
   }
   return $query;
}

Please let me know if this helps.
Thanks,
Shane

#619042

Hi, I tried your code and it still breaks the way the banners display:

hidden link

hidden link

#619190

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Johan,

So we are running into another issue now.

Because we are on an archive page the other views that are on this page will be affected.

However you can try using the solution below to only display from a specific CPT an it should only affect the current view and not any other view.
https://toolset.com/forums/topic/remove-cpt-from-categorycategory-slug-page-2/

Please let me know if this helps.
Thanks,
Shane

#619206

Wow thanks, that was actually such a simple solution. Duh!!!