Support » Fixing WordPress » How to get Post Title outside the loop

  • Resolved Jason_333


    I noticed <?php the_title(); ?> doesn’t work outside the loop. What would be a good way of calling the post title outside the loop.


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


    dint get u exactly …

    but try this

          $catposts = get_posts('numberposts=10&category=17');
          foreach($catposts as $post) :
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
       <?php endforeach; ?>

    you can use this for showing only titles of post from a partioular category…here 10 is the number of posts and 17 is the category id



    Forum Moderator

    How about using wp_title() or single_post_title()?



    Thanks guys, esmi: <?php single_post_title(); ?> did the trick. Thanks.

    On the same subject, I have a bit of code that outputs a ‘you are here’ kind of thing, but it gets displayed before the loop.

    How do I get the single_post_title() for that post when the code generating it is before the loop?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to get Post Title outside the loop’ is closed to new replies.