Forums

get post custom works if there is only 1 post in category. Fails if more than 1. (4 posts)

  1. stuartt
    Member
    Posted 3 years ago #

    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?

  2. stuartt
    Member
    Posted 3 years ago #

    *chirp, chirp, chirp*

  3. stuartt
    Member
    Posted 3 years ago #

    These forums are very active. Such a useful resource!

  4. stuartt
    Member
    Posted 3 years ago #

    Quite the graveyard, these forums. I have found Expression Engine to be much more useful in the support forum regard. Oh well, still have to support WordPress in my legacy sites.

Topic Closed

This topic has been closed to new replies.

About this Topic