Support » Plugins » Hacks » wp_query latest post

  • I have been attempting to display my latest post on the home page of my site but I cant understand why my code wont work? can anyone help?

    Thanks, Byron

            $latest_post = new WP_Query("showposts=1");
            if($latest_post->have_post()) :
        <div class="boxBar">
            <h1 class="boxedHeader">
                <?php the_title() ?>
            <?php endwhile ?>
        <?php endif ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael


    Forum Moderator

    what exactly happens with the ‘wont work’?
    i.e. what is the result?

    see all parameters for WP_Query()

    possibly try:

    $latest_post = new WP_Query("post_type=post&posts_per_page=1&orderby=date&order=DESC");

    thanks for the reply, that still didnt get it working unfortunately

    the problem is the title isnt being displayed, neither is the div ‘boxBar’ and all content after, without the php all html elements display ok

    oh my god, I cant believe how simple the problem was, i missed the s off the end of have_posts()

    think its too late, time for bed haha

    thanks anyway for your time

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_query latest post’ is closed to new replies.