WordPress.org

Ready to get started?Download WordPress

Forums

Sort By with the_post_thumbnail (2 posts)

  1. bluedrag
    Member
    Posted 1 year ago #

    Hi all,

    I have a category page which displays a post title and featured image (with the_post_thumbnail code) I'm trying to assort the posts within it by descending name. Is there a simple way to do this? Below is my category page code.

    <?php
    /**
     * The template for displaying Category Archive pages.
     *
     * @package Toolbox
     * @since Toolbox 0.1
     */
    
    get_header(); ?>
    
    		<section id="primary">
    			<div id="content" class="product_gallery" role="main">
    
    			<h1 class="cat_title"><?php single_cat_title(); ?></h1>
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    			<div class="product_thumbnail">
    			<a href="<?php the_permalink() ?>">
    			<?php //the_post_thumbnail grabs the post's "featured image" this feature has added theme support in the child theme functions.php ?>
    			<?php the_post_thumbnail('thumbnail', array('class' => 'thumbnail')); ?>
    			</a>
    
    			<?php //This piece of code figures out the corrosponding post_title of the featured image ?>
    			<p class="post_caption"><?php echo get_post(get_post_thumbnail_id())->post_title; ?></p>
    			</div> <!-- product_thumbnail -->
    
    				<?php
    					// If comments are open or we have at least one comment, load up the comment template
    					if ( comments_open() || '0' != get_comments_number() )
    						comments_template( '', true );
    				?>
    
    			<?php endwhile; // end of the loop. ?>
    
    			<br class="clear" />
    			</div><!-- #content -->
    		</section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  2. esmi
    Forum Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic