我正在创建一个WP主题。我的搜索功能无法正常工作。 当我点击搜索按钮时,什么也没有发生,它甚至不会刷新页面。但是当我输入URL www.example.com/?s=Lorem时,我得到了结果。我不明白为什么我的搜索按钮不起作用。谁能告诉我如何解决这个问题?下面你将看到我的search.php和searchform.phpWordPress搜索不起作用
的search.php
<?php get_header(); ?>
<main role="main">
<!-- section -->
<section>
<h1><?php echo sprintf(__('%s search-form Search Results for ', 'mytheme'), $wp_query->found_posts); echo get_search_query(); ?></h1>
<?php get_template_part('loop'); ?>
</section>
<!-- /section -->
</main>
<?php get_footer(); ?>
searchform.php
<div id="search">
<button type="button" class="close" style="background:transparent;border-radius: 0px;">x</button>
<form method="get" id="searchform" action="<?php echo esc_url(home_url('/')); ?>">
<input type="search" value="" name="s" placeholder="<?php if (!empty($theme_options['search_placeholder'])) { echo $theme_options['search_placeholder']; } ?>" />
<button type="submit" class="btn btn-primary"><?php _e('Search', 'mytheme'); ?></button>
</form>
</div>
此代码对我的作品与twentysixteen主题,但占位自然显示为空。当你var_dump($ theme_options)会发生什么? –