0

Hi I'm attempting to create my own custom template that will have a format like this:

<?php get_header(); ?>

    <div id="container">

      <div id="top-half">
      <!--fixed content here that is stored in the page template-->
      </div>

           <div id="bottom-half">
   <!--Content pulled from the actualpage that has this template assigned to it-->
           </div>
 </div>
<?php get_footer(); ?>

Right now I'm using <?php the_content(); ?> and instead of pulling the page content, it's pulling a specific post from my post list. I'm not quite sure why this is happening.

UPDATE: The code below was located in a widget that was being processed just before the Wordpress loop took effect in my template. I didn't reset my query using wp_reset_query(); so Wordpress displayed only a single post.

    <?php query_posts('p=63'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile;?>
2
  • can you try to clarify your question. I see in the comments below that you said wp_reset_query() fixed your problem, but that doesn't seem to answer the question you've asked. I think you either need to be more specific or expand your code snippet. Since this site tries to leave behind "canonical" answers that will help other people, it's important to help the community by asking well-worded, specific questions.
    – mrwweb
    Commented Jun 21, 2012 at 0:12
  • thanks mrwweb, I changed the question around a bit. Thanks for the input, I think this post should be a little more helpful now.
    – Rob Myrick
    Commented Jun 21, 2012 at 15:25

2 Answers 2

3

You pull content normally. You don't have to specify any id, as page/post will use template it is assigned to, so I don't really understand your question.

4
  • Thank you OriginalExe for your help. I had a sidebar display in the top half of my template and I needed to use wp_reset_query(); to display the content. I was going nuts!
    – Rob Myrick
    Commented Jun 20, 2012 at 23:28
  • What function are you using to get the content in your sidebar? If you are getting a list of posts or something similar, you should be using get_posts() and not query_posts(). Commented Jun 20, 2012 at 23:53
  • Yes, I am using query_posts(). What is the reasoning behind your suggestion?
    – Rob Myrick
    Commented Jun 21, 2012 at 0:18
  • Read here about drawbacks of using query_posts() more than once. codex.wordpress.org/Function_Reference/query_posts#Caveats Commented Jun 21, 2012 at 15:53
0

Here is what worked for me:

   <?php query_posts('p=63'); ?>
   <?php while (have_posts()) : the_post(); ?>
   <?php the_content(); ?>
   <?php endwhile;?>

   <?php wp_reset_query(); ?>
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.