我想在搜索结果中添加一个按钮”找不到运动鞋?单击此处”。此按钮将用作到另一个页面的链接, 客户可以在该页面上提交自定义订单。请告诉我该按钮的编码位置。
我尝试在search.php中添加按钮代码, 但按钮未出现在搜索结果页面中
“
<?php if ( $postCount > 8 ) { ?>
<div class="row">
<div class="col-sm-12">
<div class="search-form-wrapper u-mb-30">
<div class="search gensearch__wrapper kl-gensearch--<?php echo zget_option( 'zn_main_style', 'color_options', false, 'light' ); ?>">
<?php get_search_form(); ?>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="row">
<div class="col-sm-12">
<a class="btn" href="">Not found Desired Sneakers? Click here</a>
</div>
</div>
</section>
“
#1
假设你正在使用默认的WordPress搜索页面, 则可以通过全局wp_query访问结果数。
global $wp_query;
$customOrderPageId = 10; // UPDATE with your custom order page ID
$searchTerm = get_search_query() // If you want a flexible "Desired Sneakers" based on what the user is searching...
if ($wp_query->found_posts == 0) {
echo '<a class="btn" href="'.get_permalink($customOrderPageId).'">Not found '.$searchTerm.'? Click here</a>';
}
评论前必须登录!
注册