function widget($args, $instance) { wp_enqueue_script('jquery-isotope'); $cache = wp_cache_get('widget_related_videos', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($argsxx['widget_id'])) { $argsxx['widget_id'] = $this->id; } if (isset($cache[$argsxx['widget_id']])) { echo $cache[$argsxx['widget_id']]; return; } ob_start(); extract($args); $tags = empty($instance['tags']) ? '' : $instance['tags']; $postformat = empty($instance['postformat']) ? '' : $instance['postformat']; $title = empty($instance['title']) ? '' : $instance['title']; $title = apply_filters('widget_title', $title); $orderby = empty($instance['sortby']) ? '' : $instance['sortby']; $count = empty($instance['count']) ? '' : $instance['count']; $posttypes = 'post'; if (function_exists('ot_get_option')) { $themes_pur = ot_get_option('theme_purpose'); } if ($themes_pur == '0') { $postformat = ''; } if (is_single()) { if ($tags == '') { $tag = ''; $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { $tags .= ',' . $tag->slug; } $tags = substr($tags, 1); } } } $item_loop_video = new CT_ContentHelper(); $the_query = $item_loop_video->tm_get_related_posts($posttypes, $tags, $postformat, $count, $orderby, $args = array()); //$the_query = new WP_Query($args); $html = $before_widget; if ($title) { $html .= $before_title . $title . $after_title; } if ($the_query->have_posts()) { $html .= ' <div class="widget-content"> <div class="list-rating-item row"> '; $item_video = new CT_ContentHtml(); $i = 0; while ($the_query->have_posts()) { $the_query->the_post(); $i++; $html .= $item_video->get_item_related($postformat, $themes_pur); } $html .= '</div> </div>'; } $html .= $after_widget; if (is_singular('post') && $tags != '') { echo $html; } wp_reset_postdata(); $cache[$argsxx['widget_id']] = ob_get_flush(); wp_cache_set('widget_popular_videos', $cache, 'widget'); }