Support » Themes and Templates » get_post_custom(); doesn't work in loop, looking for work around…

  • Resolved nadine00



    I’m trying to pull all the custom fields associate with a post. I can’t seem to do this. Basically here’s the code I’m using. Its straight from the codex, in the loop:

     	 	 	  $custom_fields = get_post_custom();
     	 	 	  $my_custom_field = $custom_fields['my_custom_field'];
     	 	 	  foreach ( $my_custom_field as $key => $value )
     	 	 	    echo $key . " => " . $value . "<br />";

    I don’t know why this isn’t working. I’ve tried this as well:

    which is fine for getting the keys, but when i get to the values, i can’t just pull a full list of values, it always wants a key.

    Sooo….does anyone have either a suggestion as to why the codex code dosen’t work?

    Or, perhaps another way to pull all the values?

    I really need a hand with this, because I am totally stumped and have been trying to find a work around for ages. <?php the_meta(); ?> …works, but unfortunately I can’t format anything with it. Unless there is a filter i can toss in the functions file? That might help.

    so in short: HELP. Please?

    Thank You


Viewing 1 replies (of 1 total)
  • Hmm. I think i found something that works in this case, but its still weird that get_post_custom() just flaked out.

Viewing 1 replies (of 1 total)
  • The topic ‘get_post_custom(); doesn't work in loop, looking for work around…’ is closed to new replies.