0
votes

I am a little bit new in Wordpress and I am wondering what is the best practice to do this. So , basically, I have one site only, but it has different templates, I created a custom post type and because is a custom post type I can define its own page template, so, thats perfect, but , I have many others coming, I read that is possible to create a custom template for pages, is it possible to create it for categories?

What about the multi template plugins? are they recommendable?

Thanks.

1
codex.wordpress.org/Template_Hierarchy WordPress codex has a visual aid that explains how to do this. - KnightHawk
Thank you, I will read this information and give the feedback - jpganz18

1 Answers

1
votes

In Wordpress, you can specify templates for pages setting the next at the beginning of a php file (for example template-XXX.php):

<?php
/**
 * Template Name: XXXXX
 */

And then select XXXXX in your CMS page editor.

For the custom posts you have just to create next files in your themes:

archive-{post_type}.php 
  • If your custom post type were 'product', and/or query_var = "product", WordPress would look for archive-product.php to display the archive of posts.

    single-{post_type}.php

  • If your custom post type were 'product', and/or query_var = "product", WordPress would look for single-product.php to display the single or permalink of the post.

For categories :

category-{slug}.php
  • If the category's slug were news, WordPress would look for category-news.php

And finally, taxonomies:

taxonomy-{taxonomy}-{term}.php

  • If the taxonomy were sometax, and taxonomy's term were someterm WordPress would look for taxonomy-sometax-someterm.php. In the case of Post Formats, the taxonomy is 'post_format' and the terms are 'post_format-{format}. i.e. taxonomy-post_format-post-format-link.php

taxonomy-{taxonomy}.php

  • If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php