rendo ricercabile CPT #wp #search #customize
<?php | |
//aggiungo custom post type su cui effettuare la ricerca | |
function ek_add_post_type_to_search( $query ) { | |
if ( is_admin() || ! $query->is_main_query() ) { | |
return; | |
} | |
if ( $query->is_search() ) { | |
$query->set( | |
'post_type', | |
array( | |
'moduli' | |
) | |
); | |
} | |
} | |
add_filter( 'pre_get_posts', 'ek_add_post_type_to_search' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment