Displaying custom posts on a specific page in wordpress

I have created custom posts and I want one page in my site to have 5 of the most recent of the custom post displayed like so:

<h1>Custom Posts 1</h1>
//show 5 of the most recent custom-posts-1 here

<h1>Custom Posts 2</h1>
//show 5 of the most recent custom-posts-2 here

How would I do this? I’ve looked at the wordpress post template file but I need to be able to tell my page what posts to use. I was hoping to find for a simple function I just add to my page’s editor (I have enabled it so I can add php in) but I can’t find an appropriate one.

Related posts

Leave a Reply

1 comment

  1. I’d recommend having the two groups of posts in different WordPress categories.

    Then you can use get_posts to pull back the two different lists and print them out however you want.

    <?php
        //A rough example
        $posts = get_posts(array( 
                   'numberposts'   => 5,
                   'category_name' => 'custom-posts-2',
                   'orderby'       => 'post_date',
                   'order'         => 'DESC'
                 ));
    ?>