1 回答

TA貢獻1839條經驗 獲得超15個贊
如果有人在這里有同樣的問題,那么我所做的就是結合搜索結果并從差異中獲取。查詢類型
首先創建一個 Search-Result.php 文件,您的搜索表單將重定向到該文件。如您所見,我將搜索查詢存儲到變量并根據它獲取輸出。
<?php
$s=get_search_query();
$args = array(
's' =>$s,
'posts_per_page' => 10,
'post_type' => 'product'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<?php wc_get_template_part( 'content', 'product' ); ?>
輸出類型 2
<?php
$news=get_search_query();
$argsn = array(
's' =>$news,
'posts_per_page' => 10,
'post_type' => 'post'
);
$the_query = new WP_Query( $argsn );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
the_title();
}?>
輸出類型 3
<?php echo do_shortcode('[content-egg module=Amazon template=grid]'); ?>
這是適合我的簡單解決方案,目前我面臨很多天的問題。
- 1 回答
- 0 關注
- 145 瀏覽
添加回答
舉報