Created
January 29, 2020 13:57
-
-
Save axxe16/93e8dbdf13480d6c8564062f68befe22 to your computer and use it in GitHub Desktop.
rendo ricercabile CPT #wp #search #customize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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