我需要使用此代码更改此搜索表单代码?

时间:2012-12-27 19:25:27

标签: php wordpress search

我在wordpress的前面搜索,需要用搜索我的图库的第二个搜索替换它。我试过搞乱代码,但什么都没有用?

这是当前的搜索表单

<form method="get" id="searchbar" action="<?php echo home_url( '/' ); ?>">
<input type="search" name="s" placeholder="search...">
</form>

这是我需要的搜索

    <p class="search-box">
<label class="screen-reader-text" for="post-search-input">Search Gallery Posts:</label>
<input type="search" id="post-search-input" name="s" value=""/>
<input type="submit" name="" id="search-submit" class="button" value="Search Gallery Posts"/>
</p>
<input type="hidden" name="post_status" class="post_status_page" value="all"/>
<input type="hidden" name="post_type" class="post_type_page" value="gallery"/>
<input type="hidden" id="_wpnonce" name="_wpnonce" value="386bd8477b"/>
<input type="hidden" name="_wp_http_referer" value="/wp-admin/edit.php?post_type=gallery"/>
<div class="tablenav top">
<table class="wp-list-table widefat fixed posts" cellspacing="0">
<div class="tablenav bottom">
</form>

1 个答案:

答案 0 :(得分:0)

看起来你应该替换你的代码:

<form method="get" id="searchbar" action="<?php echo home_url( '/' ); ?>">
    <input type="search" name="s" placeholder="search...">
</form>

用这个:

<p class="search-box">
    <form method="get" id="searchbar" action="<?php echo home_url( '/' ); ?>">
        <label class="screen-reader-text" for="post-search-input">Search Gallery Posts:</label>
        <input type="search" id="post-search-input" name="s" value=""/>
        <input type="submit" name="" id="search-submit" class="button" value="Search Gallery Posts"/>
        <input type="hidden" name="post_status" class="post_status_page" value="all"/>
        <input type="hidden" name="post_type" class="post_type_page" value="gallery"/>
    </form>
</p>