WordPress.org

Forums

OptionTree
[resolved] Support for php/shortcode (6 posts)

  1. nlsubtitles
    Member
    Posted 2 years ago #

    Hi,

    Been using the plugin for 2 weeks now and I really love it, it's great for customizing themes in all kinds of ways!

    I just tried to implement Adrotate via Optiontree Textarea_simple.
    The code just displays on the site like text. I tried some things with return ot_get_option instead of echo but I can't get it to work.

    I think I can understand why it's not working, the adrotate functionname is echoed and that's it. It needs to read that line php a second time to actually run the function or something?
    Probably talking gibberish:D

    So is there any way to get this to work?

    http://wordpress.org/extend/plugins/option-tree/

  2. Derek Herman
    Member
    Plugin Author

    Posted 2 years ago #

    There is no support for php or shortcodes in the textarea. However, a quick fix for the shortcodes is to run the output of the textarea through the do_shortcode() function. PHP on the other hand is a much more complicated venture.

    http://codex.wordpress.org/Function_Reference/do_shortcode

  3. nlsubtitles
    Member
    Posted 2 years ago #

    Works perfect! Thanks again Derek!!

  4. davidjs
    Member
    Posted 2 years ago #

    Could you provide a php example of this. How do you merge a do shortcode and an option tree function.
    <?php echo get_option_tree('frontpage_featurerow_text'); ?>
    <?php echo do_shortcode( $frontpage_featurerow_text); ?>

  5. Derek Herman
    Member
    Plugin Author

    Posted 2 years ago #

    First you would not echo it, you'd save it as a variable and then pass that to do_shortcode or something like this:

    `<?php echo do_shortcode( get_option_tree( 'frontpage_featurerow_text' ) ); ?>

    That should work. It's not tested, but should anyhow.

  6. patrickd
    Member
    Posted 2 years ago #

    This worked for me but with some issues. They may not have to do with Option Tree but I hope someone can at least help me narrow down where the problem lies.

    When I am not logged in the content of the shortcode is only sometimes displayed. Also, from that point down the document is not rendered! When I remove the shortcode from the option tree option field, the document fully renders when not logged in.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • OptionTree
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.