سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

Try echoing the post meta with this:

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

Could be about, getting post ID.

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

Also, you should use this inside loop.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top