Support » Fixing WordPress » Use the_widget() inside functions.php

  • Resolved tiagofaia

    (@tiagofaia)


    Hi .

    I’m trying to create a shortcode with some html and a widget, but the widget is printing outside the divs. I think I can’t use the_widget(), the right way would be get_widget(), but doesn’t exists any get_widget()…

    The widget it’s showing before my divs.

    My code:

    // Calendar shortcode
    
    function calendarevents_function()
    {
    	$a1 = "<div class='parallax-img content-area'><div class='site-content' role='main'><div class='entry-content'>";
    	$a2= "</div></div></div>";
    
    return ($a1.the_widget('TribeEventsMiniCalendarWidget').$a2);
    }
    
    add_shortcode('calendarevents', 'calendarevents_function');

    Any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Use the_widget() inside functions.php’ is closed to new replies.