Tell us what you are trying to do?
- We have a page that shows all posts but we need to exclude one from the pages results and taxonomy filter - Podcasts
hidden link
Is there any documentation that you are following?
- i have been readign through the support forum
Is there a similar example that we can see?
N/A
What is the link to your site?
hidden link
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
Thank you for getting in touch.
You should be able to do this with the function below.
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_available_terms
This allows you to modify the terms that are being retrieved by the frontend filter.
Thanks,
Shane
Hi Shane. I have tried this put it did not work. My PHP is a little rust. How woudl you write this to exclude the category "podcast" for a view with an ID of "7664"?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
The code should look like.
add_filter( 'wpv_filter_taxonomy_frontend_search_available_terms', 'prefix_modify_list_of_terms', 10, 3 );
function prefix_modify_list_of_terms( $terms, $taxonomy, $view_id ) {
$curated_terms = array();
if($view_id == 7664){
foreach ( $terms as $term ) {
if ( $term->slug != 'podcast' ) {
$curated_terms[] = $term;
}
}
}
return $curated_terms;
}
Please try this and let me know if it helps.
Thanks,
Shane
Hi Shane. I added the code but its still showing Podcasts: hidden link
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
I checked the link and saw that the Podcast option was not showing. See Screenshot.
So it appears that the code is working as intended.
Thanks,
Shane
Hi Shane, It is not showing in the dropdown because we added this js code:
jQuery(function($){
var arr=['podcast'];
$('select[name="wpv-blog-category"] option').each(function(){
if(jQuery.inArray($(this).val(), arr)>=0){
$(this).hide();
}
});
})
We need to have it removed from the archive itself.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
This solution works as well.
Not sure if you would want to proceed with the PHP hook. If so then you can provide me with admin access so that I can perform further tests to see why the code isn't working.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
I'm trying to log into the site using the sftp but it doesn't seem to be working. I'm also not able to add any custom code to the site because of the permissions on the wordpress directory.
Thanks,
Shane
Hi Shane. I have updated the SMTP details. Can you try now? Please use port 2222 just in case?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
I've added the code to the site, however can you let me know if you're still able to see the Podcast option.
Thanks,
Shane
Hi Shane. I had to disable the code as the site was showing a critical error. Can you please check again?
I just commented out the code.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
Where was the code that you commented out located? As the code I added to the site is still active.
Thanks,
Shane
I saw it in the functions.php file? Did you add it somewhere else?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Mark,
I actually added the code at Toolset->Settings -> Custom Code.
However the code seems to be working given that "podcast" is no longer being shown in the available dropdown options.
Thanks,
Shane