这是代码:
<?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;?>
请帮助有点紧急。我真的很感激。