Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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 在插件短标签中添加customfield_Php_Wordpress_Variables_Custom Fields_Shortcode - Fatal编程技术网

Php 在插件短标签中添加customfield

Php 在插件短标签中添加customfield,php,wordpress,variables,custom-fields,shortcode,Php,Wordpress,Variables,Custom Fields,Shortcode,我正在使用wordpress插件短标签,它需要一个字段来通过自定义字段加载。我想知道如何在插件php代码中回显customfield。我是php的初学者,因此无法理解: 这是我的密码: <?php $custom_fields = get_post_custom(); $my_custom_field = $custom_fields['donationbar']; foreach ( $my_custom_field as $value ) echo "$value"; ###

我正在使用wordpress插件短标签,它需要一个字段来通过自定义字段加载。我想知道如何在插件php代码中回显customfield。我是php的初学者,因此无法理解:

这是我的密码:

<?php

$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['donationbar'];
foreach ( $my_custom_field as $value )
    echo "$value"; ### <-- that value
我想在
目标id
中加载
$value
。这样,我只需要在自定义字段中添加目标ID,其余的将硬编码到主题中。

哈哈,我想我明白了

以下是工作代码:

$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['donationbar'];
foreach ( $my_custom_field as $value )

donation_can_donation_form(
    $goal_id = $value, $show_progress = true, $show_description = false,
    $show_donations = false, $show_title = false, $title = "", $return = false
);
$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['donationbar'];
foreach ( $my_custom_field as $value )

donation_can_donation_form(
    $goal_id = $value, $show_progress = true, $show_description = false,
    $show_donations = false, $show_title = false, $title = "", $return = false
);