Sorry, I just detected your message.
Please could you follow this small guide? If it does not help, write to me here again. I will need to know the theme you're using and, possibly, the URL of your website to make some checks.
Do we have ability to sort and filter search result? For example, filter result by pages / pdf / doc / etc? Sort by relevance or date?
Maybe you have values that I can use to rewrite a query?
Hi @ilocimwca
Yes, of course, all the same values that you're usually using for WP_Query() will work!
You can specify parameters in case you want to call WP_Query() manually or you can use the pre_get_posts hook in case you want to intercept the main query.
What do you actually plan to do?
@epsilonadmin I planned pre_get_posts. How to filter to show only pdf or only web pages?
Hi @ilocimwca
It's simple to do with this addon
https://fulltextsearch.org/wpfts-addon-files-only-1.0.1.zip
It contains some code to limit post_type to 'attachment' only:
add_action('pre_get_posts', function(&$wpq)
{
if ($wpq->is_search && $wpq->is_main_query()) {
$wpq->set('post_type', array('attachment'));
$wpq->set('post_status', array('inherit'));
}
});
Pretty simple. If you want to set up your own post_types, just modify this code. You can read about full WP_Query() parameters at the Wordpress official documentation.