[wp-hackers] Select Menu to filter results by Custom Values

Otto otto at ottodestruct.com
Fri Nov 21 22:03:08 GMT 2008


You're getting back "Array" because when single = false, then it
returns an array of all the metas for that post with that key.

Simple example of getting more than one meta value:

$timearray = get_post_meta($post->ID, 'time', false);
foreach ($timearray as $time) {
echo $time;
}


On Fri, Nov 21, 2008 at 3:32 PM, Kelter-BadCat Design <kelter at badcat.com> wrote:
> Thanks Jennifer,
>
> I've been to these pages already -
>
> I seem to get just text returned back stating "Array" when using:
> <?php echo get_post_meta($post->ID, 'time', $single = false); ?>
>
> If I change to --
> <?php echo get_post_meta($post->ID, 'time', $single = true); ?>
>
> It "works" but then I only get the data from the first post delivered to the
> page.
>
> I've even tried variants of...
> <?php $key="time"; echo get_post_meta($post->ID, $time, $single = true); ?>
> to no avail.
>
> The next step of getting this returned into a select menu also fails.
>
> -Kel
>
>
>
> At 11:42 AM -0800 11/21/08, Jennifer Hodgdon wrote:
>>
>> scribu wrote:
>>>
>>> Also, you'll have to use a custom query, something like " SELECT * FROM
>>> $wpdb->postmeta WHERE key='time' "
>>
>> I don't think that is necessary. The get_post_meta() function should
>> return the whole array, and get_post_custom gives you all the post meta in
>> one big array.
>>
>> http://codex.wordpress.org/Function_Reference/get_post_meta
>> http://codex.wordpress.org/Function_Reference/get_post_custom
>>
>>   --Jennifer
>>
>> --
>> Jennifer Hodgdon * Poplar ProductivityWare
>> www.poplarware.com
>>
>> Drupal/WordPress Sites, Themes, Modules/Plugins
>> Custom Web Programming, Web Databases
>> PHP, Perl, MySQL, JavaScript, XML, AJAX
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list