-
Author
-
June 4, 2017 at 02:19 #163350
vdk
ParticipantHello,
I have a question about search results.
I was able to add a new action, so that I can choose what kind of post types wil be displayed in the search result page.
Here’s what I did and it’s working fine:
COPY CODE<span style="background-color: #e4e4ff">add_action</span><span style="background-color: #f7faff">( </span><span style="color: #008000;background-color: #f7faff;font-weight: bold">'pre_get_posts'</span><span style="background-color: #f7faff">, </span><span style="color: #000080;background-color: #f7faff;font-weight: bold">function</span><span style="background-color: #f7faff">( </span><span style="color: #660000;background-color: #f7faff">$query </span><span style="background-color: #f7faff">) { </span> <span style="color: #000080;background-color: #f7faff;font-weight: bold">if</span><span style="background-color: #f7faff">( </span><span style="color: #660000;background-color: #f7faff">$query</span><span style="background-color: #f7faff">->is_main_query() && ! is_admin() && </span><span style="color: #660000;background-color: #f7faff">$query</span><span style="background-color: #f7faff">->is_search() ) { </span> <span style="color: #660000;background-color: #f7faff">$query</span><span style="background-color: #f7faff">->set( </span><span style="color: #008000;background-color: #f7faff;font-weight: bold">'posts_per_page'</span><span style="background-color: #f7faff">, </span><span style="color: #0000ff;background-color: #f7faff">5 </span><span style="background-color: #f7faff">); </span> <span style="color: #660000;background-color: #f7faff">$query</span><span style="background-color: #f7faff">->set(</span><span style="color: #008000;background-color: #f7faff;font-weight: bold">'post_type'</span><span style="background-color: #f7faff">, </span><span style="color: #000080;background-color: #f7faff;font-weight: bold">array</span><span style="background-color: #f7faff">( </span><span style="color: #008000;background-color: #f7faff;font-weight: bold">'post'</span><span style="background-color: #f7faff">, </span><span style="color: #008000;background-color: #f7faff;font-weight: bold">'page'</span><span style="background-color: #f7faff">, </span><span style="color: #008000;background-color: #f7faff;font-weight: bold">'advert' </span><span style="background-color: #f7faff">) ); </span><span style="background-color: #f7faff"> } </span><span style="background-color: #f7faff">} );</span>However I wasn’t able to do the same thing for the ajax search.
I saw that the search is done inside kleo_ajax_search but I wasn’t able to override it in my child theme function. Could you please help me ?
Thanks
-
AuthorPosts
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic.