• I’m trying to help a friend with this problem….

    He is using a theme which contains 3 highlights sections on the homepage. The user assigns each Highlights section a specific category in the theme options panel, so each of the 3 sections display the last post from their assigned category.

    The problem is that his site only has 4 categories and many of the posts are assigned to all the same categories. Therefore, the same post often appears in 2 or sometimes all 3 of the highlights sections.

    Is there code that can be added that will prevent the same post from showing more than once? Something that will say: if post A is displayed in highlights #1, do not show post A in highlights #2 or #3.

    The website in question is: https://www.sgpspclub.com/ and the code for the highlights section is:

    <!-- Highlights // -->
    		<span class="heading2"><span>Highlights</span></span>
    		<ul class="highlights">
    		<?php $highlight1 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_1')."&showposts=1"); while($highlight1->have_posts()) : $highlight1->the_post(); ?>
    			<li>
    			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
    				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
    			<?php endif; ?>
    				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
    				<span class="cat"><?php the_category(', '); ?></span>
    			</li>
    		<?php endwhile; ?>
    
    		<?php $highlight2 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_2')."&showposts=1"); while($highlight2->have_posts()) : $highlight2->the_post();?>
    			<li>
    			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
    				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
    			<?php endif; ?>
    				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
    				<span class="cat"><?php the_category(', '); ?></span>
    			</li>
    		<?php endwhile; ?>
    
    		<?php $highlight3 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_3')."&showposts=1"); while($highlight3->have_posts()) : $highlight3->the_post();?>
    			<li>
    			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
    				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
    			<?php endif; ?>
    				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
    				<span class="cat"><?php the_category(', '); ?></span>
    			</li>
    		<?php endwhile; ?>
    
    		</ul>
    		<div class="clear"></div>
    		<!-- // Highlights -->
    		<?php endif; ?>

    Help is greatly appreciated!!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Prevent the Same Post from Showing in Multiple “Highlights” Sections’ is closed to new replies.