WordPress.org

Forums

[resolved] Add customfield inside a plugin shorttag (3 posts)

  1. beyonddesigning
    Member
    Posted 4 years ago #

    Hi All,

    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"; <-- 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.

    PS: If there is any other way to code the above function then please let me know. I'm just using what I know and could find in the docs.

    Any help would be appreciated!

  2. beyonddesigning
    Member
    Posted 4 years ago #

    Hello, anyone?

  3. beyonddesigning
    Member
    Posted 4 years ago #

    Never mind I got it:

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

Topic Closed

This topic has been closed to new replies.

About this Topic