Title: Categorise pages
Last modified: August 21, 2016

---

# Categorise pages

 *  Resolved [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/)
 * I have seen that when posts are displayed, they have a “class” of their category
   embedded within the article container.
    For example :
 *     ```
       <article class="post-49 post type-post status-publish format-standard
       hentry category-projet row-fluid" id="post-49">
           ....
       </article>
       ```
   
 * As can be seen here, the post has been categorised in the project category.
 * I would like to be able to equally categorise pages that I create – or something
   like it.
 * Why ?
 * Well, this would enable me to change the format-icon definition depending on 
   the category used.
 * However, I do not see any category section within the admin page for creating
   pages.
    If I try by creating a custom field, this is not output in the same way.
 * Am I pushing too far ?
    Is this kind of behaviour possible ?

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861761)
 * Look at the body tag of your categories pages.
 *  Thread Starter [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861772)
 * Sorry, but I do not see where you are referring to.
    There are no categories 
   for pages.
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861779)
 * Sorry I thought you meant categories pages, you meant wordpress pages.
    You want
   to categorize pages, you can do that, for example.. using the same template. 
   Isn’t that beautiful but.. Create as many templates as the “cagetories pages”
   you want, and then you can style them because the template you will use will 
   be one of the class of the body tag of those pages.
 *     ```
       <body class="page page-id-48 page-template-default" itemscope itemtype="http://schema.org/WebPage">
       ```
   
 * In this case “page-template-default”, or
 *     ```
       <body class="page page-id-48 page-template page-template-custom-page-php logged-in admin-bar no-customize-support" itemscope itemtype="http://schema.org/WebPage">
       ```
   
 * if you use the custom template.. and so on
 *  Thread Starter [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861781)
 * Totally agree with you.
 * However …. my case is where I am displaying excerpts of these same pages with
   the blog articles on the home page.
    This is what you helped me with before today:
   [Adding last published pages to home page](http://wordpress.org/support/topic/adding-last-published-pages-to-home-page)
 * This is where I am lifting up the <article …> tag I mentioned at the beginning.
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861790)
 * Mmm, wanna try this?
 *     ```
       add_filter('tc_article_selectors', 'my_selectors');
       function my_selectors($selectors){
           global $post;
           if ($post -> post_type == 'page'){
               $page_id = get_the_ID();
               $template_slug = get_page_template_slug( $page_id );
   
               if ( ! empty($template_slug) )
                   $class = 'page-template-' . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
               else
                  $class = 'page-template-default';
   
               $selectors = str_replace('class="','class="'.$class.' ', $selectors);
           }
           return $selectors;
       }
       ```
   
 * This will put the above mentioned template class in the article class.
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861796)
 * p.s.
    mostly copied from here: [https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/post-template.php#L594](https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/post-template.php#L594)
   😛
 *  Thread Starter [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861842)
 * Excellent !
    Thank you for this excellent work. +1 😉
 *  Thread Starter [SimonGiddings](https://wordpress.org/support/users/simongiddings/)
 * (@simongiddings)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861843)
 * Resolved
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861955)
 * Totally missed your reply, sorry.
    Glad you solved 😀

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Categorise pages’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/customizr/4.4.24/screenshot.png)
 * Customizr
 * [Support Threads](https://wordpress.org/support/theme/customizr/)
 * [Active Topics](https://wordpress.org/support/theme/customizr/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/customizr/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/customizr/reviews/)

## Tags

 * [pages](https://wordpress.org/support/topic-tag/pages/)

 * 9 replies
 * 2 participants
 * Last reply from: [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/categorise-pages/#post-4861955)
 * Status: resolved