• Resolved bttmrc

    (@bttmrc)


    Hello,

    I’m using divi and it’s CPT named projects.
    I want to show the projects categories in the repeater.

    I tried to add this: <?php the_category( ‘ ‘ ); ?>
    But it doesn’t show anything (maybe that is only for WP Posts?)

    Can someone shed some light here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Solved this issue offline.
    @bttmrc was using custom taxonomy, not standard WP categories.

    
    <?php 
    	global $post;
    	$terms = get_the_terms( $post->ID, 'product_category'); // Get all product_category terms
    	$classes = '';
    	if($terms){
    		foreach ( $terms as $term ) {
    			$classes .= ' '. $term->slug; // Build classes
    		}
    	}
    ?>
    <li class="grid-item insp-full<?php echo $classes; ?>"> 
       <a class="ilink" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
          <?php the_post_thumbnail('alm-cta'); ?>
       </a>
    </li>
    
    Thread Starter bttmrc

    (@bttmrc)

    Yep that solved it, thank you very much

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display category of CPT in the repeater’ is closed to new replies.