I'm trying to determine how to directly reference a category in my loop. I created a new template page based off of the Blog template. This will be to display only posts from the category "latest-news."
I think I found out how to do it, but the code appears to be from earlier versions of wordpress.
Here's what I tried.
<?php query_posts('category_name=world-dryer-events'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $args = array(' offset'=> 0, 'paged'=>$paged, 'posts_per_page' => get_option('posts_per_page'), 'post_type' => 'post' ); $all_posts = new WP_Query($args); while($all_posts->have_posts()) : $all_posts->the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ $format = get_post_format(); if( false === $format ) $format = 'standard'; get_template_part( 'postformats/'.$format, 'medium' ); ?> <?php endwhile; endwhile; ?>
The part I'm mainly concerned about is the first bit where I attempt to filter the posts down to posts from category "latest-news":
<?php query_posts('category_name=world-dryer-events'); ?>
I've also seen it done like these:
Anybody know how to make that first line filter only posts from the category I mentioned?