Display posts from certain category
-
Hello,
I am using the Illdy theme. There is a section of the front page that uses a loop to display the most recent posts. I want to modify the loop so that it shows only posts from a specific category. I have read through a lot of the WP Documentation about how to do this, and I thought that the pre_get_posts hook could work… but I haven’t had any success.
I am trying to display only posts from the “vespers” category (number 4273). Here is the original loop:
<?php if ( $post_query->have_posts() ): ?> <div class="section-content"> <div class="container"> <div class="row"> <?php $counter = 0; ?> <?php while ( $post_query->have_posts() ): ?> <?php $post_query->the_post(); ?> <?php $post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'illdy-front-page-latest-news' ); ?> <a href="<?php the_permalink(); ?>"> <div class="illdy-blog-post col-md-4 col-sm-6 col-xs-12"> <div class="post" style="<?php if ( ! $post_thumbnail ): echo 'padding-top: 40px;'; endif; ?>"> <?php if ( $post_thumbnail ): ?> <div class="post-image" style="background-image: url('<?php echo esc_url( $post_thumbnail[0] ); ?>');"></div> <?php endif; ?></a> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-title"><?php the_title(); ?></a> <div class="post-entry"> <?php the_excerpt(); ?> </div><!--/.post-entry--> <a href="<?php the_permalink(); ?>" title="<?php _e( 'Read more', 'illdy' ); ?>" class="post-button"><i class="fa fa-chevron-circle-right"></i><?php _e( 'Read more', 'illdy' ); ?> </a> </div><!--/.post--> </div><!--/.col-sm-4--> <?php $counter ++; ?> <?php if ( $counter % 3 == 0 ) { ?> <div class="clearfix"></div> <?php } ?> <?php endwhile; ?> </div><!--/.row--> </div><!--/.container--> </div><!--/.section-content--> <?php endif; ?>
Any ideas on how to modify it to get what I’m looking for?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display posts from certain category’ is closed to new replies.