Show category posts featured image
-
Hi,
I’m no really good at php, and I’m fighting to have the post of a category displayed, by featured image.
To get the featured image, I use a code found on the codex, which is the only one that auto-crops the featured image (without me resinzing it with photoshop), and I succeeded to modify it to make it work the way I want, but when I apply it to one of my categories (with a template for each category like category-test.php), it shows EVERY post that have a featured image.I tried almost everything I found on the codex : get_gategory_by_ID, by_slug, the_category, get_the_category, is_category, in_category, query_post… And I tried it at different place in my code.
So, I now need help, and sorry if this has been solved somewhere, I didn’t found it.
Here is my code in my template category.
<?php if ( have_posts() ) : ?> </header><!-- .archive-header --> <div class="category-titles"> Tous mes <?php single_cat_title(); ?> et articles mode</div> <ul id="posts-thumb-list"> <?php /* The loop */ ?> <?php $thumbnails = get_posts( 'numberposts=1000' ); foreach ( $thumbnails as $thumbnail ) { if ( has_post_thumbnail( $thumbnail->ID ) ) { echo '<div class="thumb-box"><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">'; echo get_the_post_thumbnail( $thumbnail->ID, 'thumbnail' ); echo '<div class="thumb-title-div"> <span class="thumb-title">' . get_the_title ( $thumbnail->ID ) . '</span></div>'; echo '</a></div>'; } } ?> </ul> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?>
Thanks
- The topic ‘Show category posts featured image’ is closed to new replies.