2

Is there a way to display shortcode content outside of the_content?

I am building a custom theme who's theme options includes two text boxes that can be displayed on the front page. I want to be able to display shortcode content placed in these text box options. The theme uses files from the Options Framework.

3

You can use the function do_shortcode() for use shortcodes outside fomr default content. You can also parse this in your function, there get the output of your textfields, like the follow example for a custom field:

if ( get_post_meta( $post->ID, 'cfield', TRUE ) )
    echo do_shortcode( get_post_meta( $post->ID, 'cfield', $single = TRUE ) );
3
  • Thanks @bueltge. The shortcode is not part of a post. It is part of the theme options. – Steve Jan 13 '13 at 12:13
  • The function works in all fields, also in your theme options. – bueltge Jan 13 '13 at 13:06
  • 2
    @Steve, do_shortcode( get_option(etc... – brasofilo Jan 13 '13 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.