I have a cpt called Faculty Members with 2 taxonomies "Leadership Category" and "Faculty Category". I created a View that displays the Faculty, but I want to only display the Faculty members that are in a Faculty Category not a Leadership Category, and have the front-end filters only show the Categories from the Faculty Category. I currently have the View embedded here:
hidden link
Everything works except on initial page load it displays all faculty members even if they are in a Leadership Category and not in any Faculty Category. So it appears the All initial filter does not actually filter according to the Taxonomy filter "Faculty Category" that I have the filter set to.
Hello. Thank you for contacting the Toolset support.
Yes - By default, view displays all results.
Do you mean that when view load the first time - you only want to displays the posts which belongs to category "Faculty Category".
If this is true- we need to add a query filter to pre-filter the view results.
If you can share access details, I am happy to share the filter.
*** 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.
Yes, when view load the first time I only want to displays the posts which belongs to category "Faculty Category". Can you just let me know where/how to add that query filter and I can do it myself.
add_filter( 'wpv_filter_query', 'func_remove_unwanted_category_posts', 99, 3 );
function func_remove_unwanted_category_posts( $query_args, $view_settings, $views_id ) {
if ( $views_id == 9999 and !isset($_GET['wpv-faculty-category']) ) {
/// YOUR CODE GOES HERE
$found_post_ids = get the post IDs belongs to "Faculty Category";
$query_args['post__in'] = $found_post_ids;
}
return $query_args;
}
Where:
- Replace 9999 with your original view ID and adjust the code accordingly
Can you please share access details so I can login to your system and check whats going wrong or adjust the code accordingly.
*** 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.
This sort of works. It does exclude people who are in the Leadership taxonomy from appearing in "All". But if a Faculty Member is in a Faculty taxonomy AND a Leadership taxonomy then they too are excluded from "All". So for example if you click Music History you will see "Neal" as he is in Faculty > Music History. But because he is also in the Leadership taxonomy he does not appear in 'All" and he should.