Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top