0

I have a custom template file I've been workin on. I have this code performing a loop after it queries posts from a certain category. This works and I have each post configured with styled divs, but for some reason, on the side of the page, I have strange numbers being displayed. I don't understand where they are coming from. The most posts in a category, the more numbers.

Example #'s on page: 65138 I believe the 138 is the post ID of one of the posts being called in my while loop. I'm not sure what the 65 means. Am I using a function that is echoing these values for some reason and I don't know it??

<?php
 // Select the category to get posts from.
$posts_of_interest = query_posts('cat=5');
$num_of_posts = count($posts_of_interest);
if(have_posts()) :
while( $i <= $num_of_posts):
    $i++;
    $queried_post = get_post(the_ID());
    echo $queried_post->post_content;   
    the_post();
endwhile;
endif;
wp_reset_query();
?>  

Thanks!

1
  • 1
    Unless you absolutely need to modify the main query, you should be using get_posts() instead of query_posts(). – Joseph Leedy Aug 2 '12 at 2:59
3

change the_ID() to get_the_ID(). calling the_ID() prints the post's ID, while get_the_ID() simply returns it and allows you to use it further on.

reference : get_the_ID()

1
  • no problem! glad i could help :D – pcarvalho Aug 1 '12 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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