• Hi All!

    We can create templates for pages using a declaration at the beginning of a theme file:

    
    <? Php
    / **
    ? * Template Name: Full Width Page
    ? *
    ? * @package WordPress
    ? * Twenty_Fourteen @subpackage
    ? * @since Twenty Fourteen 1.0
    ? * /
    
    ?>
    

    This snippet creates a select field on page attributes in admin editor.
    Is there a possibility to create similar to edit categories?
    If it is not possible or recommended, why?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    If category templates is not what you are looking for, please describe what you are actually trying to accomplish. There is likely a way to do so, but it may be more involved than formatting a PHP comment in a certain way ??

    Thread Starter Raphael Figa

    (@raphaelfiga)

    I want to have the possibility of the admin to change the template of the categories direct in the wp-admin equal we can do with the pages.
    Template Names

    Moderator bcworkz

    (@bcworkz)

    Your theme probably uses comment_template() to load the theme’s comment template. The file used defaults to comments.php, but a different file can be passed to the function. So first you need a place for admins to pick a file. They could just enter the actual file name in a custom field, or you could build a nice interface in a custom meta box. The end result should be a filename is stored in post meta. It would simpler to hardcode the relationship between UI name and filename, but you could write a script similar to the one used by WP to find files with a particular comment and extract the name.

    Then on every template where comment_template() is called, change it to get the file from post meta. If no value is saved, load comments.php.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Template Names for categories’ is closed to new replies.