How to Display Multiple Custom Fields with Single Values
-
Hi,
I’m trying to find the best way of displaying the single values of lots of 10 custom fields… its a catalogue site.
I’m thinking that there must be a better way than using
get_post_meta()
10 times?$code = get_post_meta($post_id, 'code', true); $circa = get_post_meta($post_id, 'circa', true); $date = get_post_meta($post_id, 'date', true); $labels = get_post_meta($post_id, 'labels', true);
etc etc…
Database queries are not my strong point but I presume using get_post_meta() 10 times for say 10 post in a loop will make 100 queries rather than just 10… 1 for each post…. Or am I totally wrong about that?
All the other similar functions to get meta keys and values don’t seem to do this except maybe
get post custom()
which is really for multiple keys with multiple values.Layout wise I want to do different things with each value so I don’t just want them spat out in a list.
This is my first forum post and any help would be very much appreciated.
:-p
- The topic ‘How to Display Multiple Custom Fields with Single Values’ is closed to new replies.