You can create a category template named category-foo.php
this will be applied only to category with slug foo
. You can thus create custom template for different categories.
Source – Codex page for Category template
Note –
If you want to do some minor changes such as show
foo
in a category-1 andbar
on other, then It’d be good to have a singlecategory.php
and useis_category
conditional tags.
Update –
You can use get_template_part( $slug, $name )
to use different loops for different categories –
<?php
if (is_category('foo')) {
get_template_part( 'cat', 'foo' ); // It'll load cat-foo.php
} else (is_category('bar')) {
get_template_part( 'cat', 'bar' ); // cat-bar.php
} else {
//
}
?>
Related Posts:
- Display most recent post in category instead of archive?
- Single.php Active Category Class
- get_post_type_archive_link(‘post’) returns current category archive
- singular posts using archive styling
- Post-Archive like a page in a specific subdirectory
- How to view all posts (on site, not admin) that are uncategorized?
- Highlighting Current Category in the Archive and Feeds page
- Posts are not displaying on their category and tag page
- show image gallery in archives or category page
- Get posts from category from custom query
- How to organise post by category and date
- How to set a link to custom archieve page
- How to get pagination working with “Pending” Posts
- Show all posts in category
- how to show all post with its contents
- Difference between an archive and a page listing posts
- Manipulate post category after time
- How to get Category Id from Post Id ?
- Create an “All Posts” or “Archives” Page with WordPress 3.0?
- Categories box not showing on post edit pages
- List only child categories a post is in, of a specific parent category
- Add custom field to all posts in specific category
- is there a better way of combining this?
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- wp_list_categories link to first post of category instead of calling taxonomy template
- How to Add ‘Post Categories’ to the Dashboard Sidebar
- How only display all post related to category
- Add category to all post by using sql query?
- Display all months with posts and inside each month show the 5 latest posts
- How to make search for the custom post type?
- Full Width Main Post
- How to automatically apply a category based on the post title?
- Direct link to “New post” in specific category?
- Extracting post categories
- Using permalinks, category slugs, and tag slugs
- How to limit posts by category
- How do I retrieve then print the currently viewed sub categories?
- List category posts alphabetically on archive.php
- Get attachments for posts that belongs to a specific category
- How can I setup a relationship using categories in WordPress?
- Related posts by category not working right
- How to list recent posts in a wp nav menu?
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- Listing Specific Categories from Current Post with Depth
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- get_the_category listing in hierarchial order
- why does wordpress ignore the post args?
- Custom Post Type archive
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- How to call posts under a specific category on static front page?
- Give posts a particular template based on the assigned category
- Show posts on front page only
- Post is in descendant category not working in home.php
- How to get posts ordered by using their categories?
- Hide parts of the post content after typing it’s name or searching it by category
- SQL Bulk Move old posts by one author to another category
- How to display only one category in a custom post type?
- load more posts by category
- Get only X number of categories
- Display Related Posts by Category in Random
- How to show beneath posts the full category path?
- adding my posts (author posts) in menu
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Different post views for different category views
- Possible?! A contextually titled back link
- Display Current Posts Category (with the most posts)?
- How to select a category automatically based on a word in WordPress post title?
- Only the most recent post is showing on my category page (working on localhost, not live site)
- ACF date picker to trigger category change
- Get category slug of the Parent category of a Product
- exclude particular category in api
- Make categories appear random
- Exclude posts in a category on one page but show those posts on a different page
- How to make a page show posts only from specific categories without editing php files
- Get a list of categories that are related to posts
- How to show posts ordered by random [duplicate]
- How to Get Position of a Post from a category and tag
- Display new posts categories in separated divs
- Add Categories To Custom Post
- Query posts from newest category
- Display Posts by Categories
- Ajax – Post Categories and Load More
- Disable archiving of old posts?
- Need help writing loop to display posts by categories in separate divs
- Edit Posts Page but not category specific pages?
- Query post category & remove any post id
- Show post if in category
- How to display custom content in post with category XXX
- Displaying categories items among posts
- how to show posts on different pages if number of post per page is one
- Displaying different posts Via wp_list_categories()
- Is it possible to have different header style blog titles in different categories?
- How do I display the next 3 posts in the sidebar?
- Display ONLY Latest Post From Several Categories
- Add author section on Author archive posts
- Polylang – display one post into 3 categories with different lang [closed]
- Export Posts Without Categories In An XML File
- Site ‘Categories’: save an admin global setting with post metadata [closed]