Post thumbnail missing
-
I have a bunch of
taxonomy-customposttype-category.php
files to display my custom post type posts.These are pulling out the first image from the gallery that is uploaded to each post, but I had a problem whereby the first image being shown did not reflect the order that was manually chosen for that gallery (topic raised here but no replies).
So instead, I have added post thumbnails to display my featured image, using a conditional statement that if a post thumbnail is found then show that or else show the first gallery image.
On some pages this works great: https://www.redesigngroup.com/tag-portfolio/middle-east/ (see Bread Box – correctly using post thumbnail)
Whereas Bread Box is also under Food & Beverage, but it disappears altogether on that page: https://www.redesigngroup.com/tag-portfolio/food-beverage/ – it was showing until I added the post thumbnail and then it disappeared.I tested some other posts by adding a post thumbnail and they did the same thing – disappeared from Food & Beverage or Retail but showing on Middle East. The template files have the exact same code.
I can’t get those posts back showing in those categories even if I remove the post thumbnail.
Is it obvious to anyone that I’ve missed something?
Does anyone have any tips for me to try?
Thanks
Edit
Just to be clear, here is my loop:<?php $args = array( 'post_type' => 'portfolio', 'tagportfolio' => 'food-beverage', 'posts_per_page' => 10000 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $image_url = gallery_first_image(); echo '<div class="portfolio-item">'; if ( has_post_thumbnail() ) { echo '<a href="'.get_permalink().'">'; the_post_thumbnail( 'portfolio-thumb' ); echo '</a>'; } elseif ( gallery_first_image() ) { echo '<a href="'.get_permalink().'"><img src="'.$image_url.'" alt="'.get_the_title().'" title="'.get_the_title().'" /></a>'; } echo '<h2><a href="'.get_permalink().'">'; the_title(); echo '</a></h2></div>'; endwhile; ?>
- The topic ‘Post thumbnail missing’ is closed to new replies.