在插件短标签内添加自定义字段
我正在使用 WordPress 插件 Shorttag,它需要一个字段来通过自定义字段加载。我想知道如何在插件 php 代码中回显自定义字段。我是 php 初学者,所以无法弄清楚:
这是我的代码:
<?php
$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['donationbar'];
foreach ( $my_custom_field as $value )
echo "$value"; ### <-- that value
我希望这个值出现在下面的 goal_id
中:
donation_can_donation_form(
$goal_id = 'VALUE HERE', $show_progress = true, $show_description = true,
$show_donations = false, $show_title = false, $title = "", $return = false
);
我想加载 $value
在 goal_id
内。这样我只需要在自定义字段中添加目标 ID,其余的将被硬编码到主题中。
I'm using a wordpress plugin shorttag which needs one field to load through a custom field. I want to know how I can echo the customfield inside the plugin php code. I'm a beginner in php so can't figure this out:
Here's my code:
<?php
$custom_fields = get_post_custom();
$my_custom_field = $custom_fields['donationbar'];
foreach ( $my_custom_field as $value )
echo "$value"; ### <-- that value
I want this value to go in the goal_id
below:
donation_can_donation_form(
$goal_id = 'VALUE HERE', $show_progress = true, $show_description = true,
$show_donations = false, $show_title = false, $title = "", $return = false
);
I want to load the $value
inside the goal_id
. This way I will only need to add the ID of the goal in the custom fields and the rest will be hardcoded into the theme.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哈哈,我想我明白了!
这是工作代码:
Lol I think I got it!
Here is the working code: