Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author shazdeh

    (@shazdeh)

    Indeed, you can use:

    
    <?php
    
    Widget_Shortcode::get_instance()->do_widget( array(
        'id' => 'text-1'
    ) );
    

    And that will output the widget with the ID of “text-1”. Although, I would recommend to use:

    
    <?php
    
    echo do_shortcode( '[widget id="text-1"]' );
    

    Hi there,

    You are able to use the following php code inside your page template

    do_shortcode( '<yourshortcodehere>' );

    For more information on the do_shortcode, please visit this link -> https://developer.wordpress.org/reference/functions/do_shortcode/

    Please keep me posted

    Thread Starter jayapriyaaktis

    (@jayapriyaaktis)

    Thank you very much to all. It is working..

    None of these are working at all for me, I just see the code on the page or else:

    Parse error: syntax error, unexpected '<' in /home/xxx/public_html/wp-content/themes/parallax-frame-child/woocommerce/content-single-product.php on line 31

    Plugin Author shazdeh

    (@shazdeh)

    @voodoochill: from the error I’d guess you’re adding <?php tags when it’s not needed, that is causing the issue. Try adding just the line:

    
    echo do_shortcode( '[widget id="text-1"]' );
    

    If you still get error, copy the contents of your “content-single-product.php” file into pastebin.com and paste the link here, there’s a syntax error that can easily be fixed.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to use shortcode widget into php code’ is closed to new replies.