[resolved] Outputting short code in widget (3 posts)

  1. martin
    Posted 4 years ago #

    I have spent a lot of time on this now, hope for help.
    I have Simple Popup Plugin, and I have used it in 2 different php widgets with the same error, so it's got to be me and not the widget.

    The following short code works beautifully in both php widgets and text widget:
    [popup url="/waxing/popupwax.html" width="270" height="600"]<p style="font-size:16px; font-style: italic">Before and After Photos</p>[/popup]

    I would very much like to use variables for url, width, height rather than hard coding it.
    From docs it seems I should use do_shortcode() to do this.

    echo do_shortcode('[popup url="http://popupurl.com"]LINK TEXT[/popup]');

    The above isn' even using variables, but always produces the following error:
    Parse error: syntax error, unexpected T_STRING in /www/doc/www.beautysecrets.cz/www/wp-content/plugins/enhanced-text-widget/enhanced-text-widget.php(42) : eval()'d code on line 11

    I have tried so many variations and always the same.
    Thaks for your time,

  2. Oleg Dudkin
    Posted 4 years ago #

    Above code should work...
    try to use something like this

    <?php $width = 100; ?>
    [popup url="http://popupurl.com" width="<?php echo $width; ?>"]LINK TEXT[/popup]

    [Please post code snippets between backticks or use the code button.]

  3. martin
    Posted 4 years ago #

    Yep, that will be a nice hack for me, not sure why do_shortcode falls short but I am going to move on!
    Thanks a lot Oleg,

Topic Closed

This topic has been closed to new replies.

About this Topic