I read that get_template_part()
should only used by themes not plugins, I don't know if using it inside a widget function (created by the theme) is considered as a plugin or not.
Anyway, I'm trying to pass that widget variables ($myvar) to the template ('loop.php' in my case), but it doesn't fetch it even with using global $myvar;
inside the template.
Here's my widget function code:
function widget($args, $instance) {
extract( $args );
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if ($title) { echo $before_title.$title.$after_title; }
$myvar = 'start';
get_template_part('loop'); ?>
echo $after_widget;
}