WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] short code as custom field value input (6 posts)

  1. tronicscribe
    Member
    Posted 4 years ago #

    I need to make a custom field to display something outside of the_content (but still inside the loop), however this thing I need to display is the form generated by the contact form 7 plugin, which requires the insertion of its short code into the post area.

    I thought I could simply put that short code in my custom field's value area and be done with it. However it doesn't look like custom field values allow short code, since all that showed up on the page was the short code itself, not it's generated contact form.

    Is there any way to use short code in a custom field value? Thanks!

  2. tronicscribe
    Member
    Posted 4 years ago #

    Anyone know how to make this work?

  3. royscheeren
    Member
    Posted 4 years ago #

    This should do the trick:

    <?php echo apply_filters('the_content', get_post_meta($post->ID, 'your_custom_field_here', true)); ?>

  4. tronicscribe
    Member
    Posted 4 years ago #

    Thank you very much. that worked well. I'm guessing that "apply_filters" does all the work, because it looks like the rest is just the standard way to show a custom field. Is this correct? Thanks again :)

  5. indiesophical
    Member
    Posted 4 years ago #

    Hi, this may be a stupid question but where do you insert the code so that it works?

  6. Fleetstar
    Member
    Posted 4 years ago #

    @ indiesophical

    I had the same problem, but figured it out. You have to put it inside the loop but wrapped in different div's than the the_content. That worked for me.

Topic Closed

This topic has been closed to new replies.

About this Topic