Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add the post content in the header but for some reason it doesn't show anything. However it does retrieve the post content.

I wrote this:

<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<?php the_title(); ?>
<?php the_content(); ?>

I tried and and none showed anything...

Is there any way I can archive this? I really need it for the site's navigation. Thanks

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The simplest solution is to call the_post() to setup the post data before calling the template functions.

<?php if(have_posts()) : the_post(); ?>
  //your header code here
  <?php rewind_posts(); //to set the post pointer back to the beginning ?>
<?php else : ?>
  //alternative header code here
<?php endif; ?>
share|improve this answer
    
Thanks a lot it works if I put it inside the header in an if. It breaks the theme if I call it before anything. –  Lisandro Dec 15 '10 at 15:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.