Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Thanks,

            $pois = $map->pois;
            foreach ($pois as $poi) {
                if ($marker_title == 'post')
                    $poi->title = $query_post->post_title;
share|improve this question
add comment

1 Answer

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); ?>

EDIT 1

To get a custom field value inside the loop:

$key="mykey"; 
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;
$key="mykey";
echo  get_post_meta($postid, $key, true);
  • in both case the key is the custom field name...
share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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