Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question : Disable for search pages #80

Open
JoshuaCrewe opened this issue May 1, 2020 · 1 comment
Open

Question : Disable for search pages #80

JoshuaCrewe opened this issue May 1, 2020 · 1 comment

Comments

@JoshuaCrewe
Copy link

Menu order for posts is great, except when doing a search where we want most relevant results first.

Is there a way to disable this plugin functionality when just doing a search ?

@JoshuaCrewe
Copy link
Author

So far I have got :

function custom_pre_get_posts($wp_query) {
    if( is_admin() || ! $wp_query->is_main_query() ) {
        return;
    }

    if (is_search()) {
        $wp_query->set('orderby', 'relevance');
        $wp_query->set('order', 'DESC');
    }
}

add_action('pre_get_posts', 'custom_pre_get_posts');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants