?> "><?php the_title(); ?> </a></h2> <h5 class="byline"><?php largo_byline(); ?> </h5> <?php largo_excerpt($post, 4, false); ?> <?php if (largo_post_in_series()) { $feature = largo_get_the_main_feature(); $feature_posts = largo_get_recent_posts_for_term($feature, 1, 1); if ($feature_posts) { foreach ($feature_posts as $feature_post) { ?> <h4 class="related-story"> <?php _e('RELATED:', 'largo'); ?> <a href="<?php echo esc_url(get_permalink($feature_post->ID)); ?> "><?php echo get_the_title($feature_post->ID); ?> </a> </h4>
/** * Returns a short list (3 posts) of stories in the same series as the main feature **/ function homepage_series_stories_list() { global $shown_ids; $feature = largo_get_the_main_feature(largo_home_single_top()); $min = 2; $max = 3; /** * Filter the minimum number of posts to show in a series list in the * HomepageSingleWithSeriesStories homepage list. * * This is used in the query for the series list of posts in the same series * as the main feature. If fewer than this number of posts exist, the list * is hidden and the headline dominates the full box. * * Default value is 2. * * @since 0.5.1 * * @param int $var minimum number of posts that can show. */ $min = apply_filters('largo_homepage_series_stories_list_minimum', $min); /** * Filter the maximum number of posts to show in a series list in the * HomepageSingleWithSeriesStories homepage list. * * This is used in the query for the series list of posts in the same series * as the main feature. This is the maximum number of posts that will display * in the list. * * Default value is 3. * * @since 0.5.1 * * @param int $var minimum number of posts that can show. */ $max = apply_filters('largo_homepage_series_stories_list_maximum', $max); $series_posts = largo_get_recent_posts_for_term($feature, $max, $min); ob_start(); if (!empty($feature)) { ?> <h5 class="top-tag"><a class="post-category-link" href="<?php echo get_term_link($feature); ?> "> <?php echo __("More in", "largo") . " " . esc_html($feature->name); ?> </a></h5> <?php foreach ($series_posts as $series_post) { $shown_ids[] = $series_post->ID; ?> <h4 class="related-story"><a href="<?php echo esc_url(get_permalink($series_post->ID)); ?> "> <?php echo get_the_title($series_post->ID); ?> </a></h4> <?php } ?> <p class="more"><a href="<?php echo get_term_link($feature); ?> "> <?php _e('Complete Coverage', 'largo'); ?> </a></p> <?php } wp_reset_postdata(); $ret = ob_get_contents(); ob_end_clean(); return $ret; }
/** * Provides topics (categories and tags) related to the current post in The * Loop. * * @param int $max The maximum number of topics to return. * @return array of term objects. * @since 1.0 */ function largo_get_post_related_topics($max = 5) { $cats = get_the_category(); $tags = get_the_tags(); $topics = array(); if ($cats) { foreach ($cats as $cat) { if ($cat->name == 'Uncategorized') { continue; } $posts = largo_get_recent_posts_for_term($cat, 3, 2); if ($posts) { $topics[] = $cat; } } } if ($tags) { foreach ($tags as $tag) { $posts = largo_get_recent_posts_for_term($tag, 3, 2); if ($posts) { $topics[] = $tag; } } } $topics = apply_filters('largo_get_post_related_topics', $topics, $max); return array_slice($topics, 0, $max); }
function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; extract($args); // only useful on post pages if (!is_single()) { return; } $title = apply_filters('widget_title', empty($instance['title']) ? __('More About', 'largo') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($rel_topics = largo_get_post_related_topics($instance['topics'])) { ?> <div id="related-posts" class="idTabs row-fluid clearfix"> <ul id="related-post-nav" class="span4"> <li><h5><?php echo $title; ?> </h5></li> <?php foreach ($rel_topics as $count => $topic) { echo '<li><a href="#rp' . (int) $count . '">' . esc_html($topic->name) . '</a></li>'; } ?> </ul> <div class="related-items span8"> <?php foreach ($rel_topics as $count => $topic) { $rel_posts = largo_get_recent_posts_for_term($topic, $instance['posts']); ?> <div id="rp<?php echo (int) $count; ?> "> <ul> <?php // the top related post $top_post = array_shift($rel_posts); ?> <li class="top-related clearfix"> <?php $permalink = get_permalink($top_post->ID); $post_title = $top_post->post_title; echo '<h3><a href="' . esc_url($permalink) . '" title="' . esc_attr(sprintf(__('Read %s', 'largo'), $post_title)) . '">' . esc_html($post_title) . '</a></h3>'; if (get_the_post_thumbnail($top_post->ID)) { echo '<a href="' . esc_url($permalink) . '"/>' . get_the_post_thumbnail($top_post->ID, '60x60') . '</a>'; } if ($top_post->post_excerpt) { echo '<p>' . $top_post->post_excerpt . '</p>'; } else { echo '<p>' . largo_trim_sentences($top_post->post_content, 2) . '</p>'; } ?> </li> <?php // the other related posts foreach ($rel_posts as $rel_post) { echo '<li><a href="' . esc_url(get_permalink($rel_post->ID)) . '" title="' . esc_attr($topic->name) . '">' . $rel_post->post_title . '</a></li>'; } ?> </ul> <p><a href="<?php echo esc_url(get_term_link($topic)); ?> " title="<?php echo esc_attr($topic->name); ?> " target="_blank"><strong><?php printf(__('View all %1$s %2$s →', 'largo'), $topic->name, of_get_option('posts_term_plural')); ?> </strong></a></p> </div> <!-- /#rpX --> <?php } ?> </div> <!-- /.items --> </div> <!-- /#related-posts --> <?php } // if ( $rel_topics ) echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }