[Support request] Default Search Dropdown

Home Forums Support Default Search Dropdown

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #962554
    Francis

    Hi,

    I need help on how to query the custom post type and add it as a dropdown selection to the default search bar of generatepress. So far, I was able to do it for the categories. But I would also like to add post type selection. What I want to achieve is to have this format:

    [search box][post type dropdown][categories dropdown][submit button]

    Here is the current code:
    <form method=”get” class=”search-form” action=”<?php echo esc_url( home_url( ‘/’ ) ); ?>”>
    <label>
    <span class=”screen-reader-text”><?php echo apply_filters( ‘generate_search_label’, _x( ‘Search for:’, ‘label’, ‘generatepress’ ) ); // WPCS: XSS ok, sanitization ok. ?></span>
    <input type=”search” class=”search-field” placeholder=”<?php echo esc_attr( apply_filters( ‘generate_search_placeholder’, _x( ‘Search …’, ‘placeholder’, ‘generatepress’ ) ) ); // WPCS: XSS ok, sanitization ok. ?>” value=”<?php echo esc_attr( get_search_query() ); ?>” name=”s” title=”<?php echo esc_attr( apply_filters( ‘generate_search_label’, _x( ‘Search for:’, ‘label’, ‘generatepress’ ) ) ); // WPCS: XSS ok, sanitization ok. ?>”>
    </label>
    <?php wp_dropdown_categories( ‘show_option_none=Select’ ); ?>
    <input type=”submit” class=”search-submit” value=”<?php echo apply_filters( ‘generate_search_button’, _x( ‘Search’, ‘submit button’, ‘generatepress’ ) ); // WPCS: XSS ok, sanitization ok. ?>”>
    </form>

    Regards,
    Francis
    apartmentsforrentx.com

    #963043
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Where exactly did you put that code? Is the search box somewhere I can see?

    #963233
    Francis

    Hi Tom,

    I placed the code under the searchform.php of generatepress. Here is the site, https://apartmentsforrentx.com/ , it’s actually on the homepage and I used a widget to display it. And the only thing that is missing is the custom post type dropdown selector, I was able to do it for the categories. But, Im not sure what is the query for generatepress to call the cpt. Hoping that you can help me. Thanks in advance.

    Regards,
    Francis
    apartmentsforrentx.com

    #963499
    Tom
    Lead Developer
    Lead Developer

    Is the category dropdown actually working? I’m not seeing any code that would connect your chosen selection to the search query.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.