WP Questions
Can we post questions on this site? I have a particular issue that is stumping me and I need a bit of help.
Can we post questions on this site? I have a particular issue that is stumping me and I need a bit of help.
You must be logged in to post a comment.
Mark 11:09 am on December 10, 2009 Permalink
Sure, I’d ask that if it is a complicated request that we save it for the meeting so we can devote some time to it. I’d prefer to not have long debates over this casual chat board.
James Tryon 1:46 pm on December 10, 2009 Permalink
Bender Hit me up. I will help.
derekbender 4:05 pm on December 10, 2009 Permalink
So Im using the get_post_meta to pull in custom info from certain posts. Heres my code:
ID, 'test_name', true)) { ?>
ID, 'test_name'); ?>
That prints out only one item but I need it to pull all the custom fields called “test_name” (multiple custom fields with the same key). How can I modify that to pull all of them? Thanks for the help!
derekbender 4:07 pm on December 10, 2009 Permalink
That didn’t work…. heres an img: http://grab.by/17iY
Mark 6:29 pm on December 10, 2009 Permalink
So this one post has multiple meta values all named the same..’test_name’? Maybe you should create a custom taxonomy instead…
register_taxonomy($taxonomy, $object_type, $args);
Chris Scott 4:44 pm on December 15, 2009 Permalink
Passing in true to get_post_meta will get you an array if more than one value with that key is there. Where you echo it out, you’ll want to pass in true as well and then (depending on what output you’re trying for) wrap it in something like join() to separate each value with a string. e.g. (hoping this formats…)
if ($test_name = get_post_meta($post->ID, ‘test_name’, true) {
echo join(‘, ‘, $test_name);
}
Mark 5:01 pm on December 15, 2009 Permalink
Passing in true will return only the first value…
http://codex.wordpress.org/Function_Reference/get_post_meta
Let’s use this as our first workshop in the January meeting, because I think there’s a few ways to skin this cat.
Chris Scott 8:40 am on December 16, 2009 Permalink
Damn, I always get true/false mixed up
Thank for the correction, Mark.