I have a Wordpress theme that displays an excerpt of the latest posts from each category. The problem is a lot of my posts are under multiple categories, so the homepage has a bunch of duplicate stories from different categories on it. Here's a screen shot of the problem: http://i.imgur.com/ra7C5p9.png As you can see, Resident Evil and Star Trek are displayed twice. Is there any way to make it only display one post from each category without creating duplicates? I tried messing with the code but can't find a solution. Here's the part of the code that displays the posts: function xinmag_section_display( $section ) { global $xinmag_options, $xinmag_headlines; $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $xinmag_options['section_postnum'], 'category__in' => $section, 'post__not_in' => $xinmag_headlines, ); $section_posts = new WP_Query( $args ); $count = 0; if ( $section_posts->have_posts() ) { echo '<h3 class="section-title bdcolor_' . $section . '">'; printf( '<a href="%1$s" title="%2$s" class="%3$s">%2$s</a>', get_category_link( $section ) , get_the_category_by_ID( $section ), 'color_' . $section ); echo '</h3>'; $ugly_hack = ""; while ( $section_posts->have_posts() ) { $section_posts->the_post(); echo '<div class="section-item">'; if ( 0 == $count) { if ( has_post_thumbnail() ) { echo '<a href="' . get_permalink() . '">'; the_post_thumbnail( 'xinmag-section', array( 'class' => 'section-image' ,'title' => get_the_title() ) ); echo '</a>'; } echo '<h2 class="section-top"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; echo '<div class="entry-summary clearfix">'; the_excerpt(); echo '</div>'; } else echo '<h2 class="section-index"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; $count++; echo '</div>'; } } wp_reset_postdata(); } PHP: If it helps to have the theme it's called Xin Magazine and the file is "/xin-magazine/inc/lib-content.php" lines 300-343. Thanks, any help would be appreciated!
Is there an option to change the display setting to only display recent posts on the homepage, or featured posts in general rather than featured posts in each category?
Unfortunately no, that's not an option. The only two options I have both display duplicate posts from each category :-( If it could just display the latest 10 posts without worrying about categories that'd be great, not sure why that's not an option.
Looks like you'll also need magazine.php to figure this out. I read the code and it looks like I should be able to change foreach ( $sections['section'] as $section ) { to while ($x < 10) { and it should work. And it does...except it doesn't put the stories in different columns, it puts it all in a single column... wp_reset_postdata(); $sections = array(); parse_str( $xinmag_options['section_order'], $sections ); $col = 0; $column = 3; foreach ( $sections['section'] as $section ) { if ( $column > 1 && $col == 0 ) echo "\n" . '<div class="row">'; echo "\n" .'<div id="section-' . $section . '" class="section-home large-4 columns">'; $col = $col + 1; if ( $col == 3 ) $col = 0; xinmag_section_display( $section ); echo '</div>'; if ( $col == 0 ) echo '</div><!-- row -->'; //row } if ( $col > 0 ) echo '</div><!-- row -->'; ?> </div><!-- content --> PHP: