HTML wordpress 中的搜索栏

HTML search bar in wordpress

我正在尝试将搜索栏添加到我的 WordPress 博客。我意识到这可以通过 get-search-form() 快速完成。尽管如此,我还是尝试使用通用的 HTML 搜索栏来获得结果,因为我认为它看起来更好。这就是我的主题:

<div class="input-group">
  <input type="text" class="form-control" placeholder="Search">
  <span class="input-group-append">
    <button class="btn btn-primary" type="button">Go!</button>
  </span>
</div>

如何将此输入和按钮用作搜索表单?

好吧...您缺少搜索表单...

<section class="container">
<form class="mb-3" action="<?php echo esc_url( home_url() ); ?>" method="get">
<input name="s" type="text" class="form-control mb-3" placeholder="Search for kittens...">
<!--
If you want to restrict search to a specific post type...
<input type="hidden" name="post_type" value=" ...Custom post type or post, page... "> -->
<button class="btn btn-primary btn-block text-truncate hasrocket" type="submit"><span>Go!</span></button>
</form>
</section>
<style media="screen">
/* easter egg */
.hasrocket:hover span{display:none;}
.hasrocket:hover:before {content:"Take-off! ";}
</style>

只需粘贴即可立即生效。 gl。如果您有任何问题,请不要犹豫。