Skip Navigation

[Resolved] Split: View with multiple taxonomies filter

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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by umbertoZ 2 years ago.

Assisted by: Waqar.

Author
Posts
#2514403

Hi Luo, the custom shortcode worked perfectly!!!

I still have a similar issue in the same website, I suppose you will split this too.

I've the Local Ads custom post type. Each post has only one multi line custom field where we store an affiliate program script.
We assigned all the taxonomies we have (Region, Area, Towns, etc.) to Local Ads and to Sights CPTs. Local Ads has only one term assigned to one of the taxonomies, while Sights has different terms (for example, a Region, an Area, a Town).

I've built a view to display Local Ads, filtered by taxonomies, on the Sights single content template.
I've selected Local Ads post-type and I've added a query filter for each taxonomy by "page where this View is shown" and logic OR.

What I expect is to display 1 or more Local Ads on each Sight post, but what I get is a loop of Sights.

This is the view:
/wp-admin/admin.php?page=views-editor&view_id=12559

This is the Sights single template:
/wp-admin/post.php?post=225&action=edit

These are a couple of Sights examples (see at the bottom of the page):

/sight/slievemore/

/sight/newport/

cheers

#2514449

Hi,

During troubleshooting, I found the following custom code in the Toolset custom section, which is interfering with the queries globally and setting the post type to 'sight':


add_action( 'pre_get_posts', 'exclude_cpt' );
function exclude_cpt( $query ) {
  if ( $query->is_tax('region') OR $query->is_tax('discover') OR $query->is_tax('area') OR $query->is_tax('destination') OR $query->is_tax('counties') OR $query->is_tax('towns')  ) {
    $query->set( 'post_type', array('sight') );
  }
  return $query;
}

I've commented out the line $query->set( 'post_type', array('sight') ); and the view "Local Ads - by taxonomies" is showing the results from the post type "Local Ads".

I'm not sure exactly for which page or section this code was added, but it will need to be made more precise so that it doesn't affect all the queries.

regards,
Waqar

#2514575

My issue is resolved now. Thank you!