dsa122870 2011-04-15 08:50
浏览 19
已采纳

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

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.

  • 写回答

1条回答 默认 最新

  • doulu4316 2011-04-28 18:36
    关注

    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
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入