Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Custom fields within PHP shortcodes

by

Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Troubleshooting › Custom fields within PHP shortcodes

Tagged: custom fields, custom post, custom post type, shortcode

  • This topic has 1 reply, 2 voices, and was last updated 14 years, 4 months ago by amin007.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 19, 2010 at 12:48 am #2404
    georgec
    Member

    I’ve successfully inserted the PHP shortcode into my custom post template:

    <?php echo eStore_show_download_now_button(1); ?>

    However I want to replace the Product ID with a value from a custom field (“product-id”), so the store product custom post editor can just allow the user to enter the product ID number, and then the shortcode is automatically generated for that specific product ID.

    HOw would I modify the above PHP code to achieve this?

    December 19, 2010 at 10:39 pm #27536
    amin007
    Participant

    You just pass in the parameter value of the custom field “product-id” in the function.

    So first retrieve your custom field value and store it in a variable then pass that variable into the function. Here is an example code (not sure if it will work for your situation but this is how its done):

    <?php
    $product_id = get_post_meta($post->ID, 'product-id', true);
    echo eStore_show_download_now_button($product_id);
    ?>

    Here is another related post:

    https://support.tipsandtricks-hq.com/forums/topic/call-product-through-a-custom-field

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ