Can you enable live search pull up pages in addition to articles?
This support request was posted in Flatbase by kurtal
- kurtal May 12, 2016 at 8:02 pm
Hi Juan,
I want live search to come up with pages and articles. Right now, it only shows articles, but if you hit enter and look at the search results page, it includes pages.
Is there a way to enable live search to include pages?
Best,
KurtJuanfra Aldasoro May 12, 2016 at 11:37 pmHi Kurt,
I hope you are doing well.
We have thought of that and we’ve included a filter so anybody who wants to include another post type/page to the live search can do it with a simple function.
You can check our snippet here: https://gist.github.com/juanfra/72c242ec4c4b35263055
You can include that into your theme functions.php file and replace post with page and you’ll start seeing the pages within the live search.
Best,
Juan.kurtal May 14, 2016 at 12:22 amHey Juan,
Thanks for your quick response. So I accidentally added a ‘}’ to the end of the snippet you sent over and crashed my site (yay! jumpkick woo!).
Error message:
Parse error: syntax error, unexpected ‘}’ in C:\Users\farmeron\kb.farmeron.com\wwwroot\wp-content\themes\flatbase\functions.php on line 37I need to use FTP to fix my mistake. Do you have a copy of the theme functions.php file you can send me so that I can go in and replace the existing file?
Thanks again for your help!
Juanfra Aldasoro May 14, 2016 at 12:55 amHi,
Thanks for the follow up.
Sure, you can get a copy of the file here: https://cloudup.com/cwg9ZBR8Z5b
Remember that you can always re-download the theme and get the original files.
Best,
Juan.kurtal May 16, 2016 at 9:01 pmHey Juan,
Hopefully just one more question, I received the following error message in the live search after adding the code to include pages:
Warning: Wrong parameter count for next() in C:\Users\farmeron\kb.farmeron.com\wwwroot\wp-content\themes\flatbase\search.php on line 36
I removed next() and that seemed to fix the problem, but I wanted to know what you think is best practice in this situation.
Thanks in advance for your support!
Juanfra Aldasoro May 16, 2016 at 10:45 pmHi,
Thank you for the follow up. Would you please copy the exact code that you have added to the functions.php file?
Thank you,
Juan.kurtal May 16, 2016 at 11:04 pmfunction nice_livesearch_add_post_type( $post_types ){
$post_types[] = ‘page’;
return $post_types;
}add_filter( ‘nice_live_search_post_type’, ‘nice_livesearch_add_post_type’ );
Juanfra Aldasoro May 17, 2016 at 1:37 pmHi,
Thank you for the follow up.
Well, the problem has to do exactly with what you’ve pointed out. The next(); function. That’s because we weren’t looking to include pages in the live search at first.
So, you can keep that modified version of search.php and we’ll fix it for the upcoming version. Thanks for the catch.
Best,
Juan.kurtal May 17, 2016 at 4:24 pmGreat, I’ll go ahead and remove the next(); function then.
Thanks for your help.
This topic is marked as resolved
Only the topic author can re-open this thread.