• I have set up a custom search function on my website using WP_Query with ‘post_type’ and ‘s’. Whenever a query is run on the search the ‘post_type’ field is ignored because of the settings on ‘WP Extended Search’. How can this be resolved?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Sumit Singh

    (@5um17)

    Hi,

    I am sorry for the delay. Do you still have this issue?

    Thanks

    Thread Starter dinodigital

    (@dinodigital)

    Hi,

    Yea this is still a problem that I am having.

    Thanks

    Plugin Author Sumit Singh

    (@5um17)

    Hi,

    So you want to disable the feature of WPES while your custom query is running? Is it?

    Thanks

    Thread Starter dinodigital

    (@dinodigital)

    Hello,

    Sorry what I am trying to do is use WPES but allow it to respect my settings within the WQ_Query I am running… I want to run WPES on only certain Custom Post Types… not bring back results for ‘all’ Custom Post Types.

    Plugin Author Sumit Singh

    (@5um17)

    Hi,

    Thanks for letting me know.
    Currently, WPES settings are global and effect every search query either primary from WP or user query.
    If I remove the overriding for secondary query then some users may complain that WPES settings are not effective for secondary query.

    I am planning a new feature to solve this problem. Meanwhile, WPES adding a pre_get_posts hook to alter the post type. I know this is not a good approach but you can add your pre_get_posts hook to override WPES settings.

    The hook is added here https://plugins.trac.www.ads-software.com/browser/wp-extended-search/trunk/includes/WP_ES.php#L87 you have to run it later than WPES hook.

    PS: Please check that it is your custom query in pre_get_posts hook.

    If you need any help in that. Please let me know.

    Thanks

    I was able to solve the problem by adding a check to see if the query_vars contains post_type.

        
    public function wp_es_pre_get_posts($query) {
        if (!empty($query->is_search) && !$this->is_bbPress_search()) {
            if (!isset($query->query_vars['post_type']) && !empty($this->WP_ES_settings['post_types'])) {
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP Query Search & Post Type Issue’ is closed to new replies.