I'm trying to hack a plugin to show the contents of a custom field where its currently showing the title.

how would I get this to show a custom field called restaurants instead?


            $pois = $map->pois;
            foreach ($pois as $poi) {
                if ($marker_title == 'post')
                    $poi->title = $query_post->post_title;

i am not sure that this is place you should change the shortcode

This code retrieves several values and not one.. as i understand it you are looking to get one value back right ?

that's much simpler and doesen't require the use of "foreach"

you simply put this in the desired location

<?php echo get_post_meta($post->ID, 'restaurants', true); ?>


To get a custom field value inside the loop:

echo get_post_meta($post->ID, $key, true);


to get a custom field value outside the loop:

global $wp_query;
$postid = $wp_query->post->ID;
echo  get_post_meta($postid, $key, true);
  • in both case the key is the custom field name...
|improve this answer|||||
  • This accepts html so you can use it to link to somewhere or anything else.. – Sagive SEO Sep 1 '11 at 19:07
  • Hi Thanks for this - I know how to query a custom field - I trying to find out specifically how to get this piece of code to output the contents of acustom field rather than the post title (its code which allows users to select a variable in a google map plugin to set what shows in the baloon above a point of interest) – JorgeLuisBorges Sep 3 '11 at 11:17
  • my answer is the way to do it but i have added an edit to better explain it mate - hope this helps... – Sagive SEO Dec 20 '12 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.