Adrian
Adrian

Reputation: 2291

Search form shortcode redirects to shortcode tag istead of ?s

I have created a search form for a page and placed it in a function that gets shortcoded. But the issue is that the action of the form goes to the shortcode tag instead of ?s. For example if I do a search it will redirect to

http://www.domain.com/?search-course-provider=course+6&providers=product_cat&post_type=product

instead of

http://www.domain.com/?s=course&providers=product_cat&post_type=product

?s becomes ?search-course-provider. How can I fix this issue.

function search_course_provider() {
?>
    <div style="background: #f4f4f4; height: 150px" class="container-fluid">
        <div  class="container">
            <form action="<?php echo site_url('/'); ?>" method="get" id="searchform" class="center-block-page">
                <input id="search-course-provider" type="text" placeholder="What do you want to study?" name="search-course-provider" value="">
                <input type="submit" id="enter" alt="waiting" value="">
                <input type="hidden" value="product_cat" name="providers" />
                <input type="hidden" value="product" name="post_type" />
            </form>
        </div>
    </div>
<?php
}
add_shortcode('search-course-provider', 'search_course_provider');

Upvotes: 0

Views: 44

Answers (2)

NIRANJAN S.
NIRANJAN S.

Reputation: 317

change <input id="search-course-provider" type="text" placeholder="What do you want to study?" name="search-course-provider" value=""> to <input id="search-course-provider" type="text" placeholder="What do you want to study?" name="s" value="">

Upvotes: 2

Gerton
Gerton

Reputation: 686

That's because the name attribute of your input is search-course-provider change this to s and it shal go to the second URL

Upvotes: 1

Related Questions