As Rarst noted, the easy option would be to modify your category.php file (if you have one)
If you do not have a category.php template_, you can make one by copying your archive.php file or your index.php file with the name category.php
If you want this only for one category, you can create a custom category template:
One option to avoid having to do this would be to copy your current archive.php page (or if it does not exist, copy your index.php page) as category-<slug_name>.php
or category-<category_id>.php
where:
- would be the name of the category slug you are using. e.g. category-test.php
- would be the id of the category you are using. e.g. category-2.php
You can then style it as wanted.
If you need to show all posts, you could use the pre_get_posts filter on the category in question:
function do_my_filter_special_category( WP_Query $query ) {
if ( !is_admin() && is_main_query() && is_category( YOUR_CATEGORY_ID_HERE ) ) {
$query->set('posts_per_page', -1);
}
}
add_action('pre_get_posts', 'do_my_filter_special_category');
Another option would be to create create a custom page template:
- Copy your page.php file (or index.php if you do not have one) as pagetemplate-all-cats.php (or whatever floats your boat)
- At the top of the file, add the following code:
The below lines should be three lines at the top of the file followed by the code below it. (I have no idea how to get the comment block to show properly...)
/*
Template Name: Show All Categories
*/
$arguments = array(
'cat' => <your_category_id_here>,
'posts_per_page' => -1
);
$all_cats = new WP_Query();
if ( $all_cats->have_posts() ) {
while ( $all_cats->have_posts() ) {
$current = $all_cats->next_post();
$id = $current->ID;
echo "<p>Other Fields:</p><pre>" . print_r($current, true) . "</pre>";
}
} else {
echo "<p>No categories to show</p>";
}
You could take this a step further and create a custom meta box for your post template so that you could show which category to show posts for.
Another option would be to make all of your posts show on your blog:
- Set your front page to show the blog
- Change your posts per page to be -1 (or use the pre_get_posts filter and check for is_home() instead of is_category(n))
is_category
codex.wordpress.org/Function_Reference/is_category