[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.
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
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?
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!
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.
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.
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.
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.
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:
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