Marc Ster
Marc Ster

Reputation: 2316

Wordpress echoing a certain custom field

I am trying to echo a specific custom field named 'Price'.

I have tried

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

How can i echo the Price field?

Upvotes: 0

Views: 62

Answers (3)

Fatih Toprak
Fatih Toprak

Reputation: 1007

Could be about, getting post ID.

echo get_post_meta(get_the_ID(), 'Price', true);

Also, you should use this inside loop.

Upvotes: 1

Zeeshan Elahi
Zeeshan Elahi

Reputation: 267

You will first have to get information about current post of Wordpress in a variable. For this you can use:

global $post;

This will get all post information in variable $post.

Than you can call your function and it should work:

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

But Price should be a meta property for that post.

Upvotes: 1

MrHunter
MrHunter

Reputation: 1900

Try echoing the post meta with this:

global $post;    
echo get_post_meta($post->ID, 'Price', true);

Upvotes: 1

Related Questions