在插件短标签内添加自定义字段

发布于 2024-11-01 11:24:05 字数 667 浏览 4 评论 0原文

我正在使用 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
);

我想加载 $valuegoal_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2024-11-08 11:24:05

哈哈,我想我明白了!

这是工作代码:

$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
);

Lol I think I got it!

Here is the working code:

$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
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文