2016-12-06 4 views
0

ワードプレスでは次のコードを検索に使用します。フロントページで検索が表示されなかった理由

それが正常に動作しますが、私は、検索ボタンをクリックすると、ページの残りの部分では、それがフロントページにジャンプし、私もここで

http://www.example.com/post-title/?s=meme

へのURLの変更が検索で気づきます形。

<form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>"> 
    <input type="search" value="<?php echo get_search_query() ?>" name="s" title="Search"/> 
    <button type="submit" class="btn btn-default">Search</button> 
</form> 

答えて

0

これが起こっているワードプレスは、あなたがhttp://www.example.com/post-title/?s=memeを使用している代わりにhttp://www.example.com/?s=memeを検索するための次の形式を受け入れるため

<form role="search" method="get" action=""> 
<input type="search" value="<?php echo get_search_query() ?>" name="s" title="Search"/> 
<button type="submit" class="btn btn-default">Search</button> 

+0

次のコードを試してみてくださいは、ご返信いただきありがとうございます。まだ動作しません。 –

+0

ブラウザに「http://www.example.com/?s = meme'」と入力すると、あなたのウェブサイトに「meme」という単語がありませんか? –

+0

うん、うまくいく、http://www.example.com/?s=memeしかし、検索ボタンをクリックすると、URLは自動的にhttp://www.example.com/post-title/に変更されますか? s = meme –

関連する問題