In the past, adding this before the loop worked. Now it won’t.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'category_name' => 'Real Colorado Weddings',
'paged' => $paged
);
query_posts($args);
?>
Assuming that code works, the query_posts() must come before the loop.
In addition to that, it’s better to use category-slug instead of the name
http://codex.ww.wp.xz.cn/Function_Reference/query_posts#All_Posts_in_a_Category
I should say that code worked for my old theme. I’m completely clueless what to do with the new one.
Could you please be a bit more specific on what exactly you’re trying to do ?
- Limit the front home listing page to display only posts from one category.
- Make one certain page to display list of posts from one category.
Or else ?
Make one certain page to display a list of posts from one category. I have it working with my old theme but I have no clue what to add to this code to get it to work now.
I have created a template file with the template name coding at the top and then copied the index code into it after the template name. Now I’m stuck. =/
Does the permalink matter ? If not, WP builds all the archive pages automatically, you can just make a link to it using this pattern.
http://example.com/category/my-cat-slug
In case you want content in that category archive page display different from others, make another copy of category.php and rename the copy with category-slug.php, where slug is that category’s slug, and make changes in it.
If it must be a page template, can you please post the whole code ( maybe using pastebin ) of that template along with loop.php so we can see what’s goin on.
Oh man. That is a million times easier than what I was trying to do. Even worse, the newer versions of WordPress seem to let you create category links on the menu that can be named whatever you want. I think one of the reasons I had to do this the hard way before was that I wanted the title on the menu to be different from the category name. I wish I would have looked at the menu customization area of the dashboard again before wasting 2 days on this. Thank you so much for alerting me to this. I feel like a class A idiot. *SMH*
Actually, this kind of thing happens to all of us at some point π