WordPress.org

Ready to get started?Download WordPress

Forums

one page view in front page (2 posts)

  1. Jibon Bikash Roy
    Member
    Posted 4 years ago #

    i want to view one recent post page in front page.i do not want it configure from wp-admin. i want source code.

  2. RGlover
    Member
    Posted 4 years ago #

    I'm not sure I understand your request, so I'll make an assumption here. My assumption is that what you want to do is include a single recent post on a static page. So, in your page template the most efficient way to do that would probably be with a WP_Query object.

    I use this in a particular area on my site.

    <?php
      $recentBlog = new WP_Query();
      $recentBlog->query('showposts=1');
      if ($recentBlog->have_posts()) : while($recentBlog->have_posts()) : $recentBlog->the_post();
    ?>
         <h2><?php the_title(); ?></h2>
         <p><?php the_content_rss('&hellip;', 0, '', 50, 0); ?></p>
         <a href="<?php the_permalink('Find Out More&hellip;'); ?>">Read More&hellip;</a>
    <?php endwhile ?>
    <?php else : ?>
          <h2>Temporary Filler Box</h2>
          <p>This is temporary filler, because the content that's supposed to go here isn't here.</p>
          <p>How terribly lazy. Come back soon, and maybe there will be something.</p>
    <?php endif ?>

    That returns the single most recent post from the blog.

    Just include something like that on the page where you want the recent post to be displayed.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.