Skip Navigation

[Resolved] Shared Taxonomy: only display posts of certain type

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

Problem:
How to display posts belongs to specific post type using taxonomy archive page

Solution:
You should create a view to display the taxonomy terms and attach post type to taxonomy term URL and using pre_get_posts hook you should filter your posts on taxonomy archive as per the selected post type.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/shared-taxonomy-only-display-posts-of-certain-type/#post-923057

Relevant Documentation:

This support ticket is created 6 years, 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 9 replies, has 2 voices.

Last updated by DianneB565 6 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#922654

I have a taxonomy which I use on 3 different post types. I now want to build a view which shows all top-level/parent categories but only for a certain post type. Lets say my post types are airplanes, cars and boats and my taxonomy is engine and the terms are 100cc, 250cc and 1000cc. I now want to build one view for each of the types which show the engine terms. If I am on the cars site and I click on 100cc, I want to see all posts which are cars and have a 100cc engine.

Currently when I click on 100cc, I will see cars, boats and airplanes with 100cc engines. Is there a way to invisibly set the post type so that the archive only shows the posts from the post type I choose?

#922787

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - do you mean you have taxonnomy archive page and on taxonomy archive you want to filter this archive with specific post type?

How user will select the specific post type? Do you have a problem URL to share?

#922983
Ad Campaigns - centralized taxonomy.png

ONE Centralized Taxonomy - Ad Programs. Separate Ad Programs using same centralized category hierarchy. Four Ad Programs. One is free.

How do I keep them separate on their specific page results and in their specific search results?

For example: Referral List is free for businesses to list their specific business under the category in which is applies. When someone wants to search the referral listing for assistance, they will only get referrals in that Ad Campaign.

Another Ad Program is Business Cards - which is a paid program with different levels for payment. I haven't gotten this far yet...the site is complex. I need help to ensure the integrity of the data with NO OVERLAP...security preventing directory traversal how to keep the WordPress database secure.

I have broken out each Ad Campaign BUT they use the same Taxonomy to ensure consistency across the board. There will be more than 10,000 businesses within the first six months. This must be done correctly!

Help.

#923003

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well, sorry, but I still do not have clear understanding about your issue as you said your site structure is complex. I only understand with the screenshot you shared is that "Referral List" is free and "Business Cards" are paid things.

Maybe it will be great if you can share few problem URLs with test case example that will help me to understand your issue first clearly so that I can guide you in right direction. Few screenshots with detailed test case example with your expected output will be great. Where you want to display what things exactly.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#923008
Ad Campaigns - centralized taxonomy.png

ONE Centralized Taxonomy. Separate Ad Programs using centralized category hierarchy. Four Ad Programs. One is free.

How do I keep Ad Programs separated onto their specific page results AND in their respective and specific search results?

For example: Referral List is a free listing for businesses to list their specific business under the category in which the business falls. When someone searches Referral Listing, only referral listings are displayed. No overlap from Business card or any other Ad Campaign. Relationship or "Access controlled" must be built into this system.

Example #2: Business Cards is a paid program with 3 different payments/levels. Data integrity with NO OVERLAP. Need to prove security is in place preventing directory traversal and WordPress database stays secure.

How can I ensure the search results for Business Cards STAYS within the Business Card search results on the Business Card page? Same issue for Referral List and other Ad Campaigns.

Keep the buckets separated, siloed, secure and searchable.

Each Ad Campaign uses the same Taxonomy for consistency. I must do this correctly!

SITEMAP is for Entire site and will display the entire result set from this page only when searched.

#923009
Ad Campaigns - centralized taxonomy.png

There isn't a back up site... This is being designed in Production. Nothing is broken, we need direction as this is NEW territory using Toolset.

ONE Centralized Taxonomy. Separate Ad Programs using centralized category hierarchy. Four Ad Programs. One is free.

How do I keep Ad Programs separated onto their specific page results AND in their respective and specific search results?

For example: Referral List is a free listing for businesses to list their specific business under the category in which the business falls. When someone searches Referral Listing, only referral listings are displayed. No overlap from Business card or any other Ad Campaign. Relationship or "Access controlled" must be built into this system.

Example #2: Business Cards is a paid program with 3 different payments/levels. Data integrity with NO OVERLAP. Need to prove security is in place preventing directory traversal and WordPress database stays secure.

How can I ensure the search results for Business Cards STAYS within the Business Card search results on the Business Card page? Same issue for Referral List and other Ad Campaigns.

Keep the buckets separated, siloed, secure and searchable.

Each Ad Campaign uses the same Taxonomy for consistency. I must do this correctly!

SITEMAP is for Entire site and will display the entire result set from this page only when searched.

#923016
Ad Campaigns - centralized taxonomy.png

I do have a taxonomy archive page for Referral List. After building the sitemap for all Category Levels 01-03 with business listing as the 04 levels, we created the Referral List Archive items. This displays everything as a Sitemap should work.

As I prepare to build the Business Card section, I only want Referral List Businesses to fall under Referral List Search results and only be viewable on the Referral List page. I don't know how to create hidden parsing methods.

There isn't a back up site... This is being designed in Production. Nothing is broken, we need direction as this is NEW territory using Toolset.

Taxonomy Archive Page: hidden link.

#923019
Ad Campaigns - centralized taxonomy.png

Today, I will build - replicate - this site into our development environment.

To answer your question. The user will specify the post type by the page selection.

Example: On Referral List page, there needs to be a hidden post type for Referral List. The same should be for other Ad Programs.

Question: is How do I create, link and test the hidden post type?

#923057

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Lets say my post types are airplanes, cars and boats and my taxonomy is engine and the terms are 100cc, 250cc and 1000cc. I now want to build one view for each of the types which show the engine terms. If I am on the cars site and I click on 100cc, I want to see all posts which are cars and have a 100cc engine.
==> I understand this requirement and for that.

To achieve above - What you should do is:
1)
=> Create a taxonomy view and add following code to loop output section of this view's loop:

<wpv-loop>
          <li> <a href="[wpv-taxonomy-url]?include_type=[wpv-post-type]"> [wpv-taxonomy-title] </a> </li>
</wpv-loop>

2)
=> Create a taxonomy archive for your taxonomy from Toolset => WordPress Archives and create archive for your taxonomy
=> add your desired content to loop output of taxonomy archive

3)
Add following code to your current theme's functions.php file:

function func_tax_archive_filter_by_posttype($query) { 
    if (is_tax('property-type') && $query->is_main_query()) {
		$query->set( 'post_type', $_GET['include_type'] );
	
    }
}
add_action('pre_get_posts', 'func_tax_archive_filter_by_posttype');

Where:
- Replace property-type with your taxonomy slug

4)
- Add the taxonomy view created at #1 to all your post types
- now load any post from any post type
- if you load the post from post type cars - it should display the posts only from cars when you click on any of taxonomy term

#923154

Minesh,

I very much appreciate your response and continually updating the ticket for me to add additional details. THANK YOU! You are awesome!