Default Search Forms - by pablostevens - on WordPress WooCommerce support

2 replies2 participantsUpdated by Olga Barlow

  • Avatar: pablostevens
    pablostevens
    Participant

    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

    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
    Participant

    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

Want to reply? Log in, or register with your ThemeForest purchase code, to reply to this topic.

Login / Register