Support » Themes and Templates » Filter recent posts by category

  • I want to filter the recent posts that appear on my homepage by category, i.e. only posts with category ‘showcase’ will appear on the homepage.

    I found some tips as how to edit the code, but I am using the Photo template from wpexplorer, which renders the homepage like this (quite differently from the loop code I came across in related questions):

    <article <?php post_class('single-entry clearfix'); ?>>
    	// Test if post has a featured image
    	if( has_post_thumbnail() ) {
    		// Get resize and show featured image : refer to functions/img_defaults.php for default values
        	$wpex_entry_img = aq_resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ),  wpex_img( 'blog_entry_width' ), wpex_img( 'blog_entry_height' ), wpex_img( 'blog_entry_crop' ) );
            <div class="single-entry-thumbnail">
                <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $wpex_entry_img; ?>" alt="<?php echo the_title(); ?>" /></a>
            </div><!-- /single-entry-thumbnail -->
        <?php } ?>
        <div class="entry-text clearfix">
                <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
        </div><!-- /entry-text -->
    </article><!-- /single-entry -->

    Anyone? It would be of great help.

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter recent posts by category’ is closed to new replies.