문제

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