Forums › Forums › Search & Filter Pro › Search and Filter Pro breaking site search pagination
Tagged: custom post type, pagination, search
- This topic has 17 replies, 2 voices, and was last updated 8 years, 8 months ago by Anonymous.
-
Ross Moderator(Private) April 7, 2016 at 8:09 pm #41987
Hey John
I managed to figure out the issue… its wasn’t easy but I used your theme locally at first…
Your theme by default adds pages to your search results (as opposed to just posts)…
And this highlighted the issue…
Its because your search results contain the S&F page with the results shortcode – that the pagination functions kick in and take over your normal pagination.. its wierd to say the least because I thought shortcodes inside pages were not executed when you use
the_excerpt()
in your template.. turns out somehow they still are :/Anyway, the quick fix is to exclude this page from your normal search results – I tested this in
functions.php
of theme you gave me and it worked (replace 12767 with the ID of your page holding the search results):function remove_id_from_search($query) { if ( !$query->is_admin && $query->is_search) { $query->set('post__not_in', array(12767) ); // id of page or post } return $query; } add_filter( 'pre_get_posts', 'remove_id_from_search' );
Now to find out how I can prevent this in the future :@
Thanks
-
AuthorPosts