开发者

Wordpress how to get the value of a custom field

Im working on my website and i'm trying to get custom fields to work. I have a page with 3 custom fields added (Experience1, Experience2, Experience3). Each of these fields have a value like "HTML/CSS - 2 Years".

Anyway I am trying to pull the value of these fields to display on part of my website. I tried using the code here but had no luck. Below is a snippet of my code:

  <ul class="about-list">
    <li><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Experience1', true);
?></开发者_运维知识库li>
    <li><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Experience2', true);
?></li>
    <li><?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Experience3', true);
?></li>
</ul>

Thanks for your help!


use like this

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜