get_posts issue

Discussion in 'WordPress' started by sixrfan, Oct 13, 2010.

  1. #1
    I'm using the code below on the homepage here (http:/www.willowbilliards.com) to display an event from the Featured Event Category (cat. 5). But for some reason, rather then display the title of the post, there's a link for HOME. How do I get the title of the post to appear instead???

    <h2>Recent Featured Event</h2>
    
    <?php
    $latestposts = get_posts('numberposts=1&category=5');
    foreach($latestposts as $post) :
       setup_postdata($post);
    ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php endforeach; ?>
    Code (markup):
    please advise. thanks in advance!
     
    sixrfan, Oct 13, 2010 IP
  2. sixrfan

    sixrfan Well-Known Member

    Messages:
    354
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    nevermind. this did the trick.

    
    <?php
    $latestposts = get_posts('numberposts=1&category=5');
    foreach($latestposts as $post) :
       setup_postdata($post);
    ?>
    <h2><a href="<?php the_permalink(); ?>"><?php echo $post->post_title; ?></a></h2>
    <?php the_content(); ?>
    <?php endforeach; ?>
    
    Code (markup):
     
    sixrfan, Oct 13, 2010 IP