Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress自定义字段– ;仅回显字段的内容,即URL_Php_Wordpress_Loops - Fatal编程技术网

Php Wordpress自定义字段– ;仅回显字段的内容,即URL

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>';

我只想回显名为“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>';

    }

如果只有一个字段,请选择

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;
}
法典对此非常清楚