• I am trying to customize a portion of a theme that displays a slider showing all posts on the site. I want it to just show posts from a certain category, such as cat=1 or cat=3.

    How do I edit this piece of code to accomplish this?
    <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

    Here is the full code for the slider.

    <section id="fromblog">
    
    				<span class="underline">
    					<h2 class="section-title"><?php _e('Drink', 'albedo'); ?></h2>
    				</span>
    
    				<div id="fromblog-desc">
    					<?php echo stripslashes_deep($theme_options['blog_desc']); ?>
    				</div>
    
    				<div class="fromblog-items-wrap">
    					<div class="flexslider carousel">
    						<ul class="slides">
    
    							<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    
    								<li class="carousel-item fromblog-post">
    									<?php if ( has_post_thumbnail() ) { ?>
    											<div class="fromblog-thumb">
    												<a href="<?php the_permalink(); ?>">
    													<?php the_post_thumbnail('fromblog'); ?>
    												</a>
    											</div>
    									<?php } ?>
    									<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    									<span class="excerpt">
    										<?php the_excerpt(50); ?>
    									</span>
    									<a href="<?php the_permalink(); ?>" class="readmore"><?php _e('Read More', 'albedo'); ?></a>
    								</li>
    
    							<?php endwhile; wp_reset_query(); ?>
    						</ul>
    					</div>
    				</div> <!-- .fromblog-items-wrap -->
    			</section><!-- #fromblog -->
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using WP_Query to Show Posts Only From Certain Categories’ is closed to new replies.