Wrong post order when modifying the_post_thumbnail
-
I am a fairly recent wordpress user and came across a weird problem: the order of my posts is wrong on my category pages. I am using the theme Emphaino, which displays posts in 3 columns. The first row of 3 columns is fine, but the first two posts of the second row are reversed. Please see https://mcbalaguer.com/?cat=29 for an example, where you will see that posts “Boulder, Colorado” and “Utah” are reversed.
After some debugging, I tracked the problem down to the function the_post_thumbnail() inside the theme’s content.php:
<?php if( has_post_thumbnail() ): ?> <div class="featured-image"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php if( 'one_col_excerpts' == get_theme_mod('posts_layout') ) the_post_thumbnail(); else the_post_thumbnail('half-width'); // PROBLEM! ?> </a> </div> <?php endif; ?>
Basically, I want the pictures to approximately be their original resolutions at ~278×371. The weird thing is that I can get the posts to show in the right order if I change the parameter of the_post_thumbnail.
More specifically, the following changes make the post appear in the correct order (but the images are too small):
the_post_thumbnail(array(300,300))
the_post_thumbnail()
the_post_thumbnail(‘medium’)
the_post_thumbnail(‘thumbnail’)
the_post_thumbnail(array(278,309))
These exhibit the same problem that I have described:
the_post_thumbnail(array(278,371))
the_post_thumbnail(array(225,371))
the_post_thumbnail(array(278,310))It seems that the size of the image is what causes the post order to be messed up, but I could not figure out why. Analyzing the page shows that an inline style parameter gets added to the article tag, which sets (incorrectly in my example) the left parameter. I could not figure out where that inline style parameter came from…
Any help would be greatly appreciated.
- The topic ‘Wrong post order when modifying the_post_thumbnail’ is closed to new replies.