Skip to content

Instantly share code, notes, and snippets.

@axxe16 axxe16/function.php
Created Jan 29, 2020

Embed
What would you like to do?
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
You can’t perform that action at this time.