get post custom works if there is only 1 post in category. Fails if more than 1.
-
I am using get_post_custom in a category template (the posts in this particular category consist of only custom fields). When there was only 1 post in the category everything worked fine. When there is more than 1 post in the category get_post_custom fails… it doesn’t return anything.
Here is how I am using it:
query_posts('cat=4&showposts=1'); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <?php $custom = get_post_custom($post->ID); ?>
It seems to me that $post->ID is not being populated (i.e. that $post” is not set) but I would have expected that by specifying query_posts as I have the most recent post for that category would be the one populating the $post object.
Where am I screwing this up?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘get post custom works if there is only 1 post in category. Fails if more than 1.’ is closed to new replies.