WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
How to add SHORTCODE to a PHP Custom Field (2 posts)

  1. yourdaddy
    Member
    Posted 2 years ago #

    I have a PHP file which i added Custom Fields PHP options, and i want to add shortcodes to the end result which is a [member] info…[/member] which basically requires to be logged in to display. How can i get this to show up?
    [member]<?php the_field(‘price’); ?>[/member]
    Doesnt work…

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. yourdaddy
    Member
    Posted 2 years ago #

    Ok to all the useless help i got, from thousands of people that must have clicked on this and decided to not even bother, I have found the solution and will share it to be remembered as someone who actually helps and supports DIY aswell as WordPress Fanatics!

    <?php $var = get_post_meta($post->ID, 'CUSTOM FIELD NAME', true); if ($var == '') { } else { echo do_shortcode( '[open your short code]' . $var . '[/close your short code]'); } ?>
    Now like i said, i was trying to apply a shortcode through a php file, using <?php echo do_shortcode("[Shortcode]"); ?>
    Didn't seem to work, as it didnt allow me to do add my <?php the_field('model_#'); ?> between opening and closing shortcodes, it would break. Obviously i was doing it wrong!

    After hundreds of Re-Worded Google Search Queries I found it and
    Used it as a guide to my solution/example code. But seem to have asked a similar/same question just worded differently.

    http://wordpress.org/support/topic/add-custom-field-within-shortcode-using-do_shortcode?replies=6

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.