/** * Display Widget * @param array $args * @param array $instance */ public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); /* Our variables from the widget settings. */ $number = $instance['number']; /* Before widget (defined by themes). */ echo $before_widget; // Display Widget ?> <?php /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } ?> <div class="aletheme-blog-widget"> <ul class="cf"> <?php $query = new WP_Query(array('posts_per_page' => $number, 'ignore_sticky_posts' => 1)); ?> <?php if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); ?> <?php $image = ale_get_og_meta_image(); ?> <?php if ($image) { /* if post has post thumbnail */ ?> <li class="cf"> <div class="entry-thumb"><a href="<?php the_permalink(); ?> "><img src="<?php echo $image; ?> " alt="" /></a></div> <?php } else { ?> <li class="cf no-thumb"> <?php } ?> <div class="detail"> <h4 class="entry-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <span class="entry-meta"><?php the_time(get_option('date_format')); ?> </span> </div> </li> <?php } } ?> <?php wp_reset_query(); ?> </ul> </div><!--blog_widget--> <?php /* After widget (defined by themes). */ echo $after_widget; }
/** * Get image for Open Graph Meta * * @return string */ function ale_og_meta_image() { echo ale_get_og_meta_image(); }