How to repeat a code
-
Dear pros,
I have a code “post by each category”. I want to use this code for more category but no need write all code again. Please help. Thank you so much
Ex this code:<div class="related-post"> <div class="related-thumb"> <?php if ( has_post_thumbnail() ): ?> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'really-simple-thumb-s', [ 'class' => 'related-thumb' ] ); ?></a> <?php elseif ( get_theme_mod('placeholder') != 'off' ): ?> <img class="related-thumb" src="<?php echo esc_url( get_template_directory_uri() ); ?>/img/thumb-medium.png" alt="<?php the_title_attribute(); ?>" /> <?php endif; ?> </div> <div class="related-category"> <?php if ( has_category() ) { the_category( ', ' ); } ?> </div> <div class="related-inner"> <div class="related-title"> <a href="<?php the_permalink();?>"><?php echo wp_trim_words( get_the_title() , 15 ) ?></a> </div> <div class="related-excerpt"><?php echo wp_trim_words( get_the_excerpt() , 50 ) ?></div> </div> </div>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to repeat a code’ is closed to new replies.