/**
  * Outputs the widget based on the arguments input through the widget controls.
  *
  * @since  0.2.0
  * @access public
  * @return void
  */
 public function widget($sidebar, $instance)
 {
     extract($sidebar);
     /* Set up the arguments. */
     $args = array('series' => !empty($instance['series']) ? $instance['series'] : '', 'order' => !empty($instance['order']) ? $instance['order'] : 'ASC', 'orderby' => !empty($instance['orderby']) ? $instance['orderby'] : 'date', 'posts_per_page' => !empty($instance['posts_per_page']) ? $instance['posts_per_page'] : -1);
     /* Output the theme's widget wrapper. */
     echo $before_widget;
     /* If a title was input by the user, display it. */
     if (!empty($instance['title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
     }
     /* Output the series. */
     series_list_posts($args);
     /* Close the theme's widget wrapper. */
     echo $after_widget;
 }
Ejemplo n.º 2
0
/**
 * Displays a list of posts related to the post by the first series.
 *
 * @since  0.1.0
 * @param  array  $args
 * @return string
 */
function series_list_related($args = array())
{
    $post_id = 0;
    if (in_the_loop()) {
        $post_id = get_the_ID();
    } else {
        if (is_singular()) {
            $post_id = get_queried_object_id();
        }
    }
    if (!empty($post_id)) {
        $series = get_the_terms($post_id, 'series');
    }
    if (empty($series)) {
        return;
    }
    $series = reset($series);
    $args['series'] = $series->slug;
    return series_list_posts($args);
}