if ( is_search() ) {
//put your search results markup here (you can copy some code from archive-product.php file and also from content-product.php to create a standard markup
} else {
// here goes the content that is already in that file (archive-product.php)
}
只需确保这行代码始终位于文件的顶部:
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
0
基于@Capital主题答案 - 您可以反转该函数并为非搜索表单类别添加代码:
<?php if (! is_search() ) {
//Added code for non search form
} else {
// if want something only for search
} ?>
2 回答
正如@arun在评论中所说,复制archive-product.php并粘贴到主题内的woocommerce文件夹中(如果你没有这个文件夹,那就创建一个)
打开文件并使用php if语句拆分该文件中的内容
只需确保这行代码始终位于文件的顶部:
基于@Capital主题答案 - 您可以反转该函数并为非搜索表单类别添加代码: