• Resolved albo75

    (@albo75)


    Love Post Snippets and would like to be able to use it with More Fields.

    My attempts at populating a field do not work however as just the [code between the brackets] is shown in my post.

    Any thoughts on how to correct this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter albo75

    (@albo75)

    Any update on this? I’d still like to be able to use it with More Fields.

    Hi,

    I’m not sure what you refer to with more fiels, could you please be a but more specific of what you are looking for?

    Cheers,
    Johan

    Hi again,

    I suppose it’s the More Field plugin you are referring to. I haven’t tried that plugin, but as far as I understand, it creates meta fields that you then output in your template by echoing out the meta?

    In that case, just wrap the meta data in a do_shortcode while echoing.

    it would be something like:
    echo do_shortcode( $meta );
    (replace $meta with how you retrieve the more fields data.) And the shortcodes you have added to the more fields should then be executed.

    Cheers,
    Johan

    Thread Starter albo75

    (@albo75)

    The More Field plugin, correct. Sorry I wasn’t specific.

    echo do_shortcode( $meta );

    This shortcode, where am I putting it exactly? The custom fields are generated via “More Fields” and I can add them to the post page via this code:

    <?php if (get_post_meta($post->ID, 'details', true) != "") { ?>
    
    <div class="block101"><?php echo get_post_meta($post->ID, 'details', true); ?></div> 
    
    <?php } ?>

    Is this where I’d add the Post Snippets code?

    Yes, to execute a shortcode contained in that meta field, update the code above to look like this

    <?php if (get_post_meta($post->ID, 'details', true) != "") { ?>
    
    <div class="block101"><?php echo do_shortcode( get_post_meta($post->ID, 'details', true) ); ?></div> 
    
    <?php } ?>

    do_shortcode() is a native WP function, that you can use to execute shortcodes in text blocks if it doesn’t do it by itself. Handy function to use now and then. ??

    Thread Starter albo75

    (@albo75)

    Perfect! Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using Post Snippets with More Fields?’ is closed to new replies.