{"id":7975,"date":"2011-04-12T05:14:19","date_gmt":"2011-04-12T09:14:19","guid":{"rendered":"http:\/\/info.template-help.com\/?p=7975"},"modified":"2017-12-19T07:53:16","modified_gmt":"2017-12-19T12:53:16","slug":"how-to-create-category-template","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/how-to-create-category-template.html","title":{"rendered":"How to create category template"},"content":{"rendered":"<p>\r\n<p>WordPress CMS allows you to create different category templates and modify the category page content and layout. Be default the category page displays a list of published posts in a chronological order starting from the most recent posts. To create category templates you should perform several steps. <\/p>\r\n<h3>Category template file name<\/h3>\r\n<p>Each category in WordPress has name, slug and ID. The category template file should contain category slug or ID. So for example if you want to create category template for the category &quot;news&quot; with ID: 5 the cateogry template file would be <strong>category-news.php<\/strong> or <strong>category-5.php<\/strong><\/p>\r\n<h3>Custom category template<\/h3>\r\n<p>The default <strong>category.php<\/strong> file content is as follows:<\/p>\r\n<pre class=\"brush:php\">\r\n\r\n&lt;?php\r\n\r\nget_header(); ?&gt;\r\n\r\n\t\t&lt;div id=\"container\"&gt;\r\n\t\t\t&lt;div id=\"content\" role=\"main\"&gt;\r\n\r\n\t\t\t\t&lt;h1 class=\"page-title\"&gt;&lt;?php\r\n\t\t\t\t\tprintf( __( 'Category Archives: %s', 'twentyten' ), '&lt;span&gt;' . single_cat_title( '', false ) . '&lt;\/span&gt;' );\r\n\t\t\t\t?&gt;&lt;\/h1&gt;\r\n\t\t\t\t&lt;?php\r\n\t\t\t\t\t$category_description = category_description();\r\n\t\t\t\t\tif ( ! empty( $category_description ) )\r\n\t\t\t\t\t\techo '&lt;div class=\"archive-meta\"&gt;' . $category_description . '&lt;\/div&gt;';\r\n\t\t\t\tget_template_part( 'loop', 'category' );\r\n\t\t\t\t?&gt;\r\n\r\n\t\t\t&lt;\/div&gt;&lt;!-- #content --&gt;\r\n\t\t&lt;\/div&gt;&lt;!-- #container --&gt;\r\n\r\n&lt;?php get_sidebar(); ?&gt;\r\n&lt;?php get_footer(); ?&gt;\r\n\r\n<\/pre>\r\n<p>Let&#8217;see what each part determines.<\/p>\r\n<p>&nbsp;<\/p>\r\n<pre class=\"brush:php\">\r\nget_header(); ?&gt;\r\n<\/pre>\r\n<p>Include the template header<\/p>\r\n<p>&nbsp;<\/p>\r\n<pre class=\"brush:php\">\r\n&lt;h1 class=\"page-title\"&gt;&lt;?php\r\nprintf( __( 'Category Archives: %s', 'twentyten' ), '&lt;span&gt;' . single_cat_title( '', false ) . '&lt;\/span&gt;' );\r\n?&gt;&lt;\/h1&gt;\r\n<\/pre>\r\n<p>Defines the page title. Category name is used as a title.<\/p>\r\n<p>&nbsp;<\/p>\r\n<pre class=\"brush:php\">\r\n$category_description = category_description();\r\nif ( ! empty( $category_description ) )\r\necho '&lt;div class=\"archive-meta\"&gt;' . $category_description . '&lt;\/div&gt;';\r\n<\/pre>\r\n<p>Adds the category description to the page if it exists. <\/p>\r\n<p>&nbsp;<\/p>\r\n<pre class=\"brush:php\">\r\nget_template_part( 'loop', 'category' );\r\n<\/pre>\r\n<p>Defines how posts will appear on the page<\/p>\r\n<p>&nbsp;<\/p>\r\n<pre class=\"brush:php\">\r\n&lt;?php get_sidebar(); ?&gt;\r\n&lt;?php get_footer(); ?&gt;\r\n<\/pre>\r\n<p>Include the template footer and sidebar<\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Using the WordPress core tags you can customize the template the way you need. <\/p>\r\n<\/p>\r\n<\/p>\r\n<p>If you need more premium templates to choose from, check out <a href=\"https:\/\/www.templatemonster.com\/wordpress-themes.php\">wordpress themes categories<\/a>.<\/p> \r\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>WordPress CMS allows you to create different category templates and modify the category page content and layout. Be default the category page displays a list of published posts in a chronological order starting from the most recent posts. To create category templates you should perform several steps. Category template file name Each category in WordPress [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[247,728],"tags":[2564,687,796,789,767,2405],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/7975"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=7975"}],"version-history":[{"count":1,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/7975\/revisions"}],"predecessor-version":[{"id":83575,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/7975\/revisions\/83575"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=7975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=7975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=7975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}