Title: Duplicate Categories
Last modified: August 21, 2016

---

# Duplicate Categories

 *  Resolved [cath77](https://wordpress.org/support/users/cath77/)
 * (@cath77)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/duplicate-categories-3/)
 * Hi
 * I hope you can help me. I have installed your plugin and added my category pictures.
   On the front page of my site I have the lasted videos (posts) listed. I would
   like the category images for each post to display on the post archives on the
   front page.
 * I have added your suggested php code to loop.php to achieve this and it works
   okay with the exception that it is repeating the category images from the first
   post onto all the others.
 * Here is the how I included the php. I am developing locally and should have the
   site up in a day or so. Can you immediately see what I can do to have mutually
   exclusive cat images show up for each post?
 * Thanks
    Catherine
 * <div class=”content-container loop-container”>
 *  <?php if ( have_posts() ) : ?>
 *  <div class=”wrapper”>
 *  <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
 *  <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
    “><h2 class=”
   entry-title”><span> <?php echo get_the_title() ? get_the_title() : __(‘Untitled’,‘
   focus’) ?>
 *  </span></h2>
 *  ** <?php foreach (get_categories() as $cat) : ?> **
 *  <div class=cat_images>
 *  <img src=”<?php echo z_taxonomy_image_url($cat->term_id); ?>” />
    term_id); ?
   >”>
 *  </div>
    <?php endforeach; ?> <div class=”clear”></div>
 *  ” class=”thumbnail-wrapper”>
    <!– <div class=”time”></div> –> <?php echo has_post_thumbnail()?
   get_the_post_thumbnail() : focus_default_post_thumbnail(); ?>
 *  </article>
 *  <?php endwhile; ?>
 *  </div>
 *  <?php else : ?>
 *  <?php get_template_part( ‘no-results’, ‘index’ ); ?>
 *  <?php endif; ?>
 *  <div class=”clear”></div>
 * </div>
 * <?php focus_content_nav( ‘nav-below’ ); ?>
 * [https://wordpress.org/plugins/categories-images/](https://wordpress.org/plugins/categories-images/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [cath77](https://wordpress.org/support/users/cath77/)
 * (@cath77)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/duplicate-categories-3/#post-4733490)
 * Hi
 * I have put up my site the link to it is
    [http://www.ispysurf.com](http://www.ispysurf.com)
 * You will be able to see on the post thumbnails that all the category images are
   being assigned to every post regardless of what categories were actually selected.
 * This has something to do with the code in the loop. Any ideas how to fix it?
 * Thanks C
 *     ```
       <div class="content-container loop-container">
   
       	<?php if ( have_posts() ) : ?>
   
       		<div class="wrapper">
   
       			<?php /* Start the Loop */ ?>
       			<?php while ( have_posts() ) : the_post(); ?>
   
       				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       					<a href="<?php the_permalink() ?>"><h2 class="entry-title"><span>
       						<?php echo get_the_title() ? get_the_title() : __('Untitled', 'focus') ?>
   
       					</span></h2></a>
   
                  <strong> <?php foreach (get_categories() as $cat) : ?>        
   
        <div class=cat_images>
   
        <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
        <a href="<?php echo get_category_link($cat->term_id); ?>"></a>
   
        </div>
        <?php endforeach; ?></strong>
        <div class="clear"></div>
   
         <a href="<?php the_permalink() ?>" class="thumbnail-wrapper">
       						<!-- <div class="time"></div> -->
       						<?php echo has_post_thumbnail() ? get_the_post_thumbnail() : focus_default_post_thumbnail();  ?>
   
       					</a>
       				</article>
   
       			<?php endwhile; ?>
   
       		</div>
   
       	<?php else : ?>
   
       		<?php get_template_part( 'no-results', 'index' ); ?>
   
       	<?php endif; ?>
   
       	<div class="clear"></div>
   
       </div>
   
       <?php focus_content_nav( 'nav-below' ); ?>
       ```
   
 *  Thread Starter [cath77](https://wordpress.org/support/users/cath77/)
 * (@cath77)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/duplicate-categories-3/#post-4733491)
 * Hi
 * I have put up my site the link to it is
    [http://www.ispysurf.com](http://www.ispysurf.com)
 * You will be able to see on the post thumbnails that all the category images are
   being assigned to every post regardless of what categories were actually selected.
 * This has something to do with the code in the loop. Any ideas how to fix it?
 * Thanks C
 *     ```
       <div class="content-container loop-container">
   
       	<?php if ( have_posts() ) : ?>
   
       		<div class="wrapper">
   
       			<?php /* Start the Loop */ ?>
       			<?php while ( have_posts() ) : the_post(); ?>
   
       <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       <a href="<?php the_permalink() ?>"><h2 class="entry-title"><span>
       <?php echo get_the_title() ? get_the_title() : __('Untitled', 'focus') ?>
   
       					</span></h2></a>
   
        <?php foreach (get_categories() as $cat) : ?>        
   
        <div class=cat_images>
   
        <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
        <a href="<?php echo get_category_link($cat->term_id); ?>"></a>
   
        </div>
        <?php endforeach; ?>
        <div class="clear"></div>
   
         <a href="<?php the_permalink() ?>" class="thumbnail-wrapper">
       <!-- <div class="time"></div> -->
       <?php echo has_post_thumbnail() ? get_the_post_thumbnail() : focus_default_post_thumbnail();  ?>
   
       					</a>
       				</article>
   
       			<?php endwhile; ?>
   
       		</div>
   
       	<?php else : ?>
   
       <?php get_template_part( 'no-results', 'index' ); ?>
   
       	<?php endif; ?>
   
       	<div class="clear"></div>
   
       </div>
   
       <?php focus_content_nav( 'nav-below' ); ?>
       ```
   
 *  Plugin Author [Zahlan](https://wordpress.org/support/users/elzahlan/)
 * (@elzahlan)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/duplicate-categories-3/#post-4733750)
 * You have to use [get_the_category](http://codex.wordpress.org/Function_Reference/get_the_category)
   instead of get_categories function

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Duplicate Categories’ is closed to new replies.

 * ![](https://ps.w.org/categories-images/assets/icon-128x128.png?rev=2256871)
 * [Categories Images](https://wordpress.org/plugins/categories-images/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/categories-images/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/categories-images/)
 * [Active Topics](https://wordpress.org/support/plugin/categories-images/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/categories-images/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/categories-images/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Zahlan](https://wordpress.org/support/users/elzahlan/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/duplicate-categories-3/#post-4733750)
 * Status: resolved