为什么have_posts(),the_post()呈现页面而不是帖子?

时间:2016-08-11 03:59:11

标签: php wordpress

大家好,所以我得到了这段代码来显示帖子,但相反或渲染帖子它呈现了关于我们页面可以任何人帮助。我正在运行WordPress 4.5.3

<?php get_header(); ?>

<?php 
    if(have_posts() ):
        while(have_posts() ) : the_post();
            the_title();
            the_content();
        endwhile;
    endif;
?>

<?php get_footer(); ?>

1 个答案:

答案 0 :(得分:0)

使用此:

$args = array(
            'posts_per_page'   => 10,
            'offset'           => 0,
            'category'         => '',
            'category_name'    => '',
            'orderby'          => 'date',
            'order'            => 'DESC',
            'include'          => '',
            'exclude'          => '',
            'meta_key'         => '',
            'meta_value'       => '',
            'post_type'        => 'post',
            'post_mime_type'   => '',
            'post_parent'      => '',
            'author'           => '',
            'author_name'      => '',
            'post_status'      => 'publish',
            'suppress_filters' => true 
        );
        query_posts($args);

        if(have_posts()): the_post();
            while(have_posts()): the_post();
            ?> 
            <h4> <?php the_title();?> </h4>

        <?php endwhile;?>
        <?php endif; ?>