I made a file as category-videos.php, since i read that either use category-[slug].php or category-[ID].php . But, i don’t know the next steps. How to link it with wordpress ? How to link all posts with this template ?
Mainly my requirement is that I want to create a new template for my specific category “VIDEOS” so that all posts under this category show in new style. Basically, i want to show posts with videos in a new way as 3 posts in one row with featured images and a featured slider on top of that page showing 4 new posts of that category ?
But i am confused… Can i do this in wordpress ? Because my home page also has a featured slider. Can i create a new slider for that page template but one thing is sure. I need to work with only one category for that custom template i.e. videos………
Any help will be appreciated. Thanks in advance ….
create a file category-[slug].php or category-[id].php – Put category’s slug for which you want a different template in [slug] or its [id]. WordPress provides this functionality by default.
See http://codex.wordpress.org/User:Lorelle/Custom_Category_Template for more information on this.
Another, not good approach is to use decision statements based on
(is_category('id'))
like
but again this is not a good approach to use too much if else – also affects your server as well as each time server side decision will be taken to display content for
if
orelse
Create category-Id.php file (for example category-1.php). You can found Id number when hover on category in admin.
You can do with this category what do you want.
For example, in my blog i have with thumbnail and without.
Another way via Is_category tag
My custom template works just fine by adding slug or id ( category-slug.php ).. WordPress will automatically find the right template according the template hierarchy. If you need the child of the category use the parent template too, use add_action(‘template_redirect’,’your_function’).