• Resolved tribethrow

    (@tribethrow)


    Hey All,

    My client would like a custom front page on his blog with several sections, one of which will include the most recent blog post.

    In my limited knowledge, I was going to make a frontpage.php template for this and include wp_get_archives(‘postbypost’, 1); to show the latest post, but I was wondering if there was a way to SHOW what the post is? I guess it would be to echo the contents of that latest post on the front page…

    Any help would be great!

    Thanks!

    Alex

Viewing 4 replies - 1 through 4 (of 4 total)
  • Equal

    (@equalmark)

    Why not create a home.php template which will then be used as the home template for the site and then display the latest blog post with:

    <?php $latestpost = new WP_Query("showposts=1"); while($latestpost->have_posts()) : $latestpost->the_post(); ?>
    
            //do stuff here
    
    <?php endwhile; ?>
    alofear

    (@alofear)

    if you want to display the date and the title of the posts, I like to use this code

    <ul id="sidebar_updates">
    <?php
        $recentPosts = new WP_Query();
        $recentPosts->query('showposts=5');
    ?>
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
        <li><strong><?php the_time('F j, Y'); ?></strong><br /><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></br></li>
    <?php endwhile; ?>
    </ul>

    save that as “recentupdates.php” and to call it on the page use

    <?php include (TEMPLATEPATH . "/recentupdates.php"); ?>

    basic CSS

    #sidebar_updates {
    	  padding:0;
    	  margin:0;
    	  }
    	#sidebar_updates li {
    	  list-style-type:none; padding-bottom:4px; padding-top:2px; font-size:12px;
    	  }

    Thread Starter tribethrow

    (@tribethrow)

    Hey guys,

    Thanks for your responses.

    Equalmark, the latest post code is exactly what I was looking for.

    Thanks guys!

    Alex

    Dear alofear

    Thank you, thank you, thank you! I’ve wasted a lot of time trying to figure out the date thing using wp_get_archives which does not include the option to display the date. Your code works! Hooray.

    I like your formatting too, especially the CSS with the indent for the repeated 1st selector. Nice job. Only if everyone would take the time to write clean code.

    I can now list the last few post archives on a sidebar with the date and title.

    I hope I can return the favor, if not to you, then to someone else

    Fredz

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_get_archives() question!’ is closed to new replies.