<?php media_center_post_header('style-2'); ?> </div> <a href="<?php the_permalink(); ?> " class="post-thumbnail pull-right" title="<?php echo sprintf(__('Post Format: %1$s', 'media_center'), $post_format_text); ?> "> <?php if (has_post_thumbnail()) { echo get_the_post_thumbnail(get_the_ID(), array(265, 265), array('class' => 'media-object')); } else { echo '<span class="mc-default-post-thumbnail">' . media_center_default_post_thumbnail($post_format) . '</span>'; } ?> </a> </div> </div> <div class="col-xs-7"> <h2 class="post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php media_center_post_meta();
function widget($args, $instance) { $cache = array(); if (!$this->is_preview()) { $cache = wp_cache_get('mc_recent_posts', 'widget'); } if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Posts', 'media_center'); $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $show_date = true; /** * Filter the arguments for the Recent Posts widget. * * @since 3.4.0 * * @see WP_Query::get_posts() * * @param array $args An array of arguments used to retrieve the recent posts. */ $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true))); if ($r->have_posts()) { ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="recent-post-list"> <?php while ($r->have_posts()) { $r->the_post(); ?> <li class="sidebar-recent-post-item"> <div class="media"> <?php if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. echo '<a href="' . get_the_permalink() . '" class="thumb-holder pull-left">' . get_the_post_thumbnail(get_the_ID(), 'thumbnail') . '</a>'; } else { echo '<a href="' . get_the_permalink() . '" class="thumb-holder pull-left mc-default-post-thumbnail">' . media_center_default_post_thumbnail(get_post_format()) . '</a>'; } ?> <div class="media-body"> <h5><a href="<?php the_permalink(); ?> "><?php get_the_title() ? the_title() : the_ID(); ?> </a></h5> <div class="posted-date"><?php echo get_the_date(); ?> </div> </div> </div> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } if (!$this->is_preview()) { $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('mc_recent_posts', $cache, 'widget'); } else { ob_end_flush(); } }