Php Wordpress自定义字段– ;仅回显字段的内容,即URL
我只想回显名为“linkto”的自定义字段的字符串,这是一个URL。我在WordPress抄本中找不到好的答案。你能帮帮我吗Php Wordpress自定义字段– ;仅回显字段的内容,即URL,php,wordpress,loops,Php,Wordpress,Loops,我只想回显名为“linkto”的自定义字段的字符串,这是一个URL。我在WordPress抄本中找不到好的答案。你能帮帮我吗 <?php if (in_category( "29" )){ echo '<a class="theid" href="'; // Here i want to echo the URL from custom field "linkto" echo '" target="_blank"> link</a>';
<?php if (in_category( "29" )){
echo '<a class="theid" href="';
// Here i want to echo the URL from custom field "linkto"
echo '" target="_blank"> link</a>';
}
如果只有一个字段,请选择
echo get_post_meta( get_the_ID(), 'your-field-name', true );
如果有多个字段使用同一个键
foreach( $values = get_post_meta( get_the_ID(), 'your-field-name', false ) as $value ) {
echo $value;
}
法典对此非常清楚