Tag Info

Hot answers tagged

2

This same exact question was asked earlier this week or over the weekend, and it had me thinking. Here is the idea that I came up with. If you look at the source code of the WP_Query class, you will see that sticky posts is only added to the first page of the home page. There is also no filter supplied to change this behavior in order to set the required ...


1

I just made it for a client, you'll have to do it on the pre_get_posts action. That means you will add parameters to the Wordpress query before it returns the posts. Add this to functions.php: // advanced search functionality function advanced_search_query($query) { if($query->is_search()) { // category terms search. if ...


1

You can try and use set_query_var() very very early, before the query is parsed and queried for, for example during the pre_get_posts action. Although thinking about it, if you're using pre_get_posts it's likely easier to do something like this (off the top of my head): add_action( 'pre_get_posts', function( $query ) { if ( ! $query->is_main_query() ...


1

Easiest and most robust way is to add a url parameter to the search so the search url will be something like http://www.example.com/?s=xyz&from404=1. Probably easiest way to do that is by adding a hidden field to the form. For "bonus points" use the browser's history API to remove the parameter after the page load.


1

If I understand you correctly you're not looking for the wp_search_stopwords filter type of solution. So here's a modification of the great answer by @kaiser that you referred to: /** * Exclude array of words from all search queries in the front-end * * Modification of http://wordpress.stackexchange.com/a/41100/26350 by @kaiser */ add_filter( ...



Only top voted, non community-wiki answers of a minimum length are eligible