Is it possible to show posts for a single category? I tried browsing to the URL http://mysite.com/category/foo which does show all of the posts with category foo, but the posts lose their formatting in the listing.

I'd like a full paginated listing of posts that keeps formatting. Do I need to write a plug-in for this? Can anyone give me some pointers on how to do so?

3 Answers
3

It sounds like you actually may need to do very little to get this working. It seems as though you have a template hierarchy issue. In WordPress, a number of variables are considered when making a decision about which template should be used to show the content generated by a specific URL. If you take a look at WordPress' Template Hierarchy, you can see how these decisions are made.

In the case of taxonomies, and more specifically, WordPress' built-in category taxonomy, WordPress looks for these templates in the following order:

category-{slug}.php - If the category's slug were news, WordPress would look for category-news.php

category-{id}.php - If the category's ID were 6, WordPress would look for category-6.php

category.php

archive.php

index.php

These files are located in your active theme's folder. If the first file is located, it will be used to display your content. If not, WordPress will look for the 2nd file and so on. If nothing is located, it will default to your index.php file.

Now, in your situation, it really sounds like you have an index.php file that is displaying posts in a way that you really like; however, when you try to access a category page, the display is different. This to me suggests that WordPress is displaying one of the files listed 1-4 and not showing the same template as your regular blog posts, which is likely index.php. So, you can fix this by doing one of two things (note, please back up your files before doing either of these options).

1) Figure out which template is displaying your category page. Copy the contents of index.php to this file

2) Delete the file that is displaying your category page and let index.php display the page.

By doing either of these options, you will be avoiding any hacky solutions that break out of the WordPress way of doing things, which will save you tons of headaches. Additionally, pagination will work without any custom solutions.

I know this may not be super simple, but feel free to ask more about this and hopefully we can get you straightened out.

Very risky to use query_posts in such a situation where it is not needed. You may change a lot of query vars, which could lead to many bugs that are very difficult to debug. Take a look at the top answer for this question to see what happens when using query_posts: wordpress.stackexchange.com/questions/1753/…
–
tollmanzNov 28 '11 at 1:57