Archive.php – Show only posts from user's selected category
-
On our wordpress website we’ve got a template that didn’t come with the category section fully working – when you click a category it shows all posts regardless of the category. I’ve had a crack at it and have got all posts appearing for the category but with no pagination, which is required.
Basically I’ve got all posts going through an IF statement, and only being shown if they are in the selected category. Ones that are not in the category just don’t echo anything out.
I want to be able to show only 5 at a time as is the usual thing to do on our websites. I imagine it might be something to do with the wp_query bit. Below is what I’ve got for that:
$wp_query = new WP_Query(); $wp_query->query(‘showposts=’.$totalposts . ‘&paged=’.$paged);
$totalposts is the amount of published posts. The full list of variables I’ve got defined is below.
- Total amount of published posts
- Selected Category name
- Selected Category ID
- The post’s associated category ID
- An incrementor counting the posts on the page as they are echoed out (counting only ones in the category
Any help is greatly appreciated, thanks.
- The topic ‘Archive.php – Show only posts from user's selected category’ is closed to new replies.