Default Search Forms - by pablostevens - on WordPress WooCommerce support

This topic has 3 replies, 2 voices, and was last updated 4 years, 5 months ago ago by Olga Barlow

  • Avatar: pablostevens
    pablostevens
    Participant
    October 24, 2019 at 20:36

    I have the search option in the theme’s settings set to “posts and pages” however, when I search for example “mississauga” it only shows posts. The search query seems wrong.

    The URL generated is:
    https://pfc.igosalesandmarketing.com/?s=mississauga&post_type=post

    And it only shows posts, it should be:

    https://pfc.igosalesandmarketing.com/?s=mississauga&post_type=post&post_type=page

    I have some custom post types that aren’t showing up. Can you direct me to where this is generated in the functions so I can add the appropriate url reference to search pages as well?

    2 Answers
    Avatar: pablostevens
    pablostevens
    Participant
    October 24, 2019 at 23:05

    Ok found this in theme-functions.php

    // **********************************************************************//
    // ! Add page to search results
    // **********************************************************************//
    add_filter( 'pre_get_posts', 'et_search_filter' );
    if ( !function_exists('et_search_filter') ) {
        function et_search_filter( $query ) {
            if ( ! is_admin() ) {
                if ( isset($query->query['post_type']) ) {
                    if ( $query->is_search && $query->query['post_type'] == 'post') {
                        $query->set( 'post_type', array( 'post', 'page' , 'industries', 'wpsl_stores' ) );
                    }
                }
                return $query;
            }
        }
    }
    

    I added my two custom post types here “industries” and “wpsl_stores”

    I just added this to the functions.php of the child theme.

    Sorry answered my own questions, but if someone else has the problem, this is the solution.

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    October 25, 2019 at 10:57

    Hello,

    We glad to hear that you sorted out and share your solution with other customers!
    Feel free to contact us if you need any other help.

    Regards

  • Viewing 3 results - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.