SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Sep 2003
    Location
    Northern California
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WordPress : Show latest post on static home page

    Building a custom theme. The home page is static although, I need to show the latest post (actually, just the first 300 chars) on the home page.

    Need to pull from a particular post category (news).

    I assume that I must use wp_query() with some parameters - instead of the default loop. Or, do I use conditional tags with the default Loop in some way.

    Thanks

  2. #2
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mgm_03 View Post
    Building a custom theme. The home page is static although, I need to show the latest post (actually, just the first 300 chars) on the home page.

    Need to pull from a particular post category (news).

    I assume that I must use wp_query() with some parameters - instead of the default loop. Or, do I use conditional tags with the default Loop in some way.

    Thanks
    Fairly simple using the following code, adjust where needed:

    PHP Code:
    <?php 
        $args 
    = array( 'numberposts' => 6'post_status'=>publish,'post_type'=>post,'orderby'=>post_date);
        
    $postslist get_posts$args );

        foreach (
    $postslist as $post) : setup_postdata($post); ?>
           <div class="recentPosts">
                 <p><strong><?php the_date(); ?></strong></p>
               <p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p> 
          </div>
    <?php endforeach; ?>
    Michael John Froseth
    Freelance Web Developer | MichaelFroseth | dotCom

  3. #3
    SitePoint Member
    Join Date
    May 2012
    Location
    Hamilton, New Zealand
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't this be fairly easy to do using widgets and a sidebar?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •