0
這是代碼:如何讓此代碼僅搜索帖子而不是頁面? (wp_query)
<?php global $wp_query;
$search_term=$_REQUEST['search-terms'];
if(empty($search_term))
$search_term=$_REQUEST['s'];
$wp_query->query("s=".$search_term);?>
<?php if (have_posts()) : ?>
<?php while(have_posts()):the_post(); global $post;?>
出於某種原因,它表明這兩個職位,並在結果頁面的頁面。我如何排除頁面並只顯示帖子?
我試過,但它不工作:
<?php global $wp_query;
$args = array_merge($wp_query->query, array('post_type' => 'post'));
query_posts($args);
$search_term=$_REQUEST['search-terms'];
if(empty($search_term))
$search_term=$_REQUEST['s'];
$wp_query->query("s=".$search_term);?>
<?php if (have_posts()) : ?>
<?php while(have_posts()):the_post(); global $post;?>
請幫助是有點急。我真的很感激。
它不工作...我應該在哪裏把你的代碼? –
它現在應該工作 – Napolux
是的,我想出了你的代碼的位置,它現在正在工作。非常感謝你。我一直在努力讓它工作幾個小時。 –