Okay
  Public Ticket #312613
Get only the most recent post
Closed

Comments

  • Kara started the conversation

    Hi Tahir,

    I created a custom post type called "Market Reports" and am displaying the page by linking it to the archives page, which can be seen here: http://www1.susanbandler.com/?post_type=marketrepo...

    I've spent quite a bit of time trying to get this archives page to just display the most recent post. However, in my attempts (which have only included changing two lines), I've managed to display the sidebar content from the most recent Portfolio item, plus the title of the most recent archive item. 

    How can I adjust the archives.php page (well, the child theme one I've created), to only get the most recent post as opposed to running the "while(have_posts())" statement. 

    Thanks,

    Kara

  •  8,406


    ThemeNectar Support Team 

  •   Kara replied privately
  •  982
    ThemeNectar replied

    Hey! Change that code to this:

    $query_arr = array(
    	'posts_per_page' => 1,
    	'post_type' => 'marketreports',
    );
    				
    query_posts($query_arr);
    
    if(have_posts()) : while(have_posts()) : the_post(); ?>