Hello!
I’m using a child theme from Travelify.
I activated the wp-pagenavi plugin and it’s not working well.
Its important to say that i’m using custom post types.
In my custom function travelify_theloop_for_search() I put:
if(get_query_var('paged')) {
$paged = get_query_var('paged');
} elseif(get_query_var('page')) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$args = array(
'post_type' => $colecao, //passed by parameter
'paged' => $paged,
'meta_query' => array(
array(
'value' => $s,
'compare' => 'LIKE',
'posts_per_page' => 10
)
)
);
// get results
$the_query = new WP_Query( $args );
The navigation is showed but not working well. Sometimes got 404, extra pages, etc.
Is there something more that i need to do?
Thanks!
WP-PageNavi plugin does work by default with this theme. You can see it in action using search result page: https://colorlib.com/travelify/?s=test
I am a bit confused why you are trying to modify loop for search?
Hi Aigars,
Thanks for the answer. Now I know what was doing wrong.
My custom query was using many custom post types in the same time.
$args = array(
'post_type' => $post_types, //$post_types is an array with all the custom types names that I created.
'paged' => $paged,
'meta_query' => array(
array(
'value' => $s,
'compare' => 'LIKE',
'posts_per_page' => 10
)
)
);
// get results
$the_query = new WP_Query( $args );
Apparently it confused the query or other thing.
After comment the array code with the custom post types it worked. I decided to keep it that way and do the searches for only one custom post type at a time.
Thanks again. Yours theme is simple and useful.