duanjianxiu9400 2014-10-22 23:31
浏览 50

如何在自定义模板上显示最近的帖子? 它正在取代Page而不是Post

This is my code : http://postimg.org/image/s7v5ircpx/

This is my page : http://postimg.org/image/v52fus50z/

What I essentially want to do is to output recent posts on my 'Events' page so that it would have a masonry styling for old posts. Additionally, when the admin wants to create a new post, it will output the post on this page while having its own customized masonry style.

I use JQuery Masonry for this.

So far the code works, it displays a block, but what it should be doing is it should display all the posts on that page, meaning it would have 60 blocks (since there's 60 posts right now), and also, it is not linking to the right content. Instead of outputting posts, this block outputs the Event page itself, the actual page that contains this block.

I have been trying to figure it out these past few hours but I'm on a dead end. I have no idea why it's linking it to the page itself and not the posts.

My code seems to be correct too.

I have tried to go to Settings -> Reading -> change Blog posts to Event, but the blog posts will only override the whole template.

  • 写回答

1条回答 默认 最新

  • dre26973 2014-10-23 08:24
    关注
    <?php $args = array(
    
        'numberposts' => 10,
        'offset' => 0,
        'category' => 0,
        'orderby' => 'post_date',
        'order' => 'DESC',
        'include' => ,
        'exclude' => ,
        'meta_key' => ,
        'meta_value' =>,
        'post_type' => 'post',
        'post_status' => 'draft, publish,
        future, pending, private',
        'suppress_filters' => true );
    
        $recent_posts = wp_get_recent_posts( $args, ARRAY_A );
    ?>
    
    评论

报告相同问题?