function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; // instance: num, series (id), title, heading extract($args); //get the posts $series_posts = largo_get_series_posts($instance['series'], $instance['num']); if (!$series_posts) { return; } //output nothing if no posts found $instance['title_link'] = get_term_link((int) $instance['series'], 'series'); $term = get_term($instance['series'], 'series'); $title = apply_filters('widget_title', $term->name, $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } //first post $series_posts->the_post(); $context = array('instance' => $instance, 'thumb' => 'medium', 'excerpt' => 'custom_excerpt'); largo_render_template('partials/widget', 'content', $context); //divider if ($series_posts->have_posts()) { echo '<h5 class="series-split top-tag">' . esc_html($instance['heading']) . '</h5><ul>'; while ($series_posts->have_posts()) { $series_posts->the_post(); echo '<li>'; post_type_icon(); echo '<a href="'; the_permalink(); echo '">'; the_title(); echo '</a></li>'; } echo '</ul>'; } echo '<a class="more" href="' . get_term_link((int) $instance['series'], 'series') . '">' . __('Complete Coverage', 'largo') . "</a>"; echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }
function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; // instance: num, series (id), title, heading extract($args); //get the posts $series_posts = largo_get_series_posts($instance['series'], $instance['num']); if (!$series_posts) { return; } //output nothing if no posts found //$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $before_widget; //if ( $title ) echo $before_title . $title . $after_title; //term link $term = get_term($instance['series'], 'series'); echo '<h5 class="top-tag"><a href="' . get_term_link((int) $instance['series'], 'series') . '">' . $term->name . '</a></h5>'; //first post $series_posts->the_post(); $instance['test'] = 'banana'; include locate_template('partials/content-tiny.php'); //divider echo '<h5 class="series-split top-tag">' . esc_html($instance['heading']) . '</h5><ul>'; while ($series_posts->have_posts()) { $series_posts->the_post(); echo '<li>'; post_type_icon(); echo '<a href="'; the_permalink(); echo '">'; the_title(); echo '</a></li>'; } echo '</ul>'; echo '<a class="more" href="' . get_term_link((int) $instance['series'], 'series') . '">' . __('Complete Coverage', 'largo') . "</a>"; echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }
?> </a> <?php } // the headline and optionally the post-type icon ?> <h5> <a href="<?php echo get_permalink(); ?> "><?php echo get_the_title(); ?> <?php if (isset($instance['show_icon']) && $instance['show_icon'] == true) { post_type_icon(); } ?> </a> </h5> <?php // byline on posts if (isset($instance['show_byline']) && $instance['show_byline'] == true) { ?> <span class="byline"><?php echo largo_byline(false); ?> </span> <?php }