Title: Where to insert the code?
Last modified: August 22, 2016

---

# Where to insert the code?

 *  Resolved [albydigei](https://wordpress.org/support/users/albydigei/)
 * (@albydigei)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/)
 * Hi, I’d like to have different categories’ colors in the home page but I can’t
   understand where I have to insert php code I should insert in the template.
 * The site is [http://pickandpopculture.it](http://pickandpopculture.it)
 * [https://wordpress.org/plugins/category-color/](https://wordpress.org/plugins/category-color/)

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

 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822375)
 * Hello, Which color you want to change on your homepage? Like the title or category
   font color or background colors etc?
 * If is it possible to share with me the code or email me personally on zayedbaloch(
   at)gmail.com.
 * Best;
 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822447)
 * Please change `<?php the category(); ?>` tag with the following code.
 *     ```
       <?php
         $categories = get_the_category();
         $separator = ' / ';
         $output = '';
         if($categories){
           foreach($categories as $category) {
               $rl_category_color = rl_color($category->cat_ID);
               $output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" style="color:'.$rl_category_color.';">'.$category->cat_name.'</a>'.$separator;
           }
           echo trim($output, $separator);
         }
       ?>
       ```
   
 *  [carlos007h](https://wordpress.org/support/users/carlos007h/)
 * (@carlos007h)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822664)
 * Hi Zayed, sorry for asking the same question, but I think this is a truly great
   solution, and very nicely solved. But I do not understand which file do I need
   to go and do the modification. Is it functions.php, . . . index.php. I’m able
   to see some strings that look like it, but not quite the same.
 * I would like to have a magazine look, were the visitor, with the colors, can 
   have a quick view of the different categories.
 * my site: [http://www.guatecultura.org](http://www.guatecultura.org)
    Thank you
   so much!!
 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822665)
 * Hi Carlos,
 * Check the index.php loop there have `<?php the_category(); ?>` function just 
   replace the the_category function with the following code.
 *     ```
       <?php
         $categories = get_the_category();
         $separator = '';
         $output = '';
         if($categories){
           foreach($categories as $category) {
               $rl_category_color = rl_color($category->cat_ID);
               $output .= '<div class="featured-cat" style="color:'.$rl_category_color.';">'.$category->cat_name.'</div>'.$separator;
           }
           echo trim($output, $separator);
         }
       ?>
       ```
   
 * Hope this will work same as you want. 🙂
 *  [manolo13](https://wordpress.org/support/users/manolo13/)
 * (@manolo13)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822673)
 * Hi Zayed!
 * That’s a wonderfull plugin. I sent you a message (zayedbaloch(at)gmail.com) regarding
   the code.
 * Trying to figure out whre should i place it. Would appreciate your help.
 * Thanks in advance.
 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822674)
 * [@manolo13](https://wordpress.org/support/users/manolo13/): Check the FAQ section
   in plugin page, hopefully it will help you.
 * [https://wordpress.org/plugins/category-color/faq/](https://wordpress.org/plugins/category-color/faq/)
 *  [Madn](https://wordpress.org/support/users/madn/)
 * (@madn)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822679)
 * Hi Zayed!
 * This is just the plugin i need but I don´t understand how to use it. I would 
   like to change some background colors and font colors of my posts depending on
   the category in my custom theme but I don´t know how. There is no <?php the_category();?
   > in my index.php ! I´m quite new in wordpress and don´t know how to make it 
   work.
 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822680)
 * Hay Madn,
 * In your custom, where you want to display the category name with the respected
   color that you already selected from category section. Just paste the following
   code on your template home or single page.
 *     ```
       <?php
         $categories = get_the_category();
         $separator = '';
         $output = '';
         if($categories){
           foreach($categories as $category) {
               $rl_category_color = rl_color($category->cat_ID);
               $output .= '<div class="featured-cat" style="color:'.$rl_category_color.';">'.$category->cat_name.'</div>'.$separator;
           }
           echo trim($output, $separator);
         }
       ?>
       ```
   
 *  [Madn](https://wordpress.org/support/users/madn/)
 * (@madn)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822681)
 * Hey Zayed!
 * Thaks a lot for your quick answer! It´s working now. I´m really happy about it!;
   D
 * Thaks and have a nice day!
 *  [Treeas](https://wordpress.org/support/users/treeas/)
 * (@treeas)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822696)
 * Hi Zayed,
    It seems you made a great plug-in. In your faq, I’m confused about
   the “<?php the_category(); ?>”string. I don’t find any in my theme. I just have
   some “$categories_list = get_the_category_list” in content.php. Thanks in advance.
 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822697)
 * [@treeas](https://wordpress.org/support/users/treeas/): If you dont have “<?php
   the_category(); ?>” then simply paste the following code on your .php file where
   you want to show the category names.
 *     ```
       <?php
           $categories = get_the_category();
           $separator = ' / ';
           $output = '';
           if($categories){
               foreach($categories as $category) {
                       $rl_category_color = rl_color($category->cat_ID);
                   $output .= '<a href="'.get_category_link( $category->term_id ).'" style="color:'.$rl_category_color.';">'.$category->cat_name.'</a>'.$separator;
               }
           echo trim($output, $separator);
           }
       ?>
       ```
   
 *  [gabry75](https://wordpress.org/support/users/gabry75/)
 * (@gabry75)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822698)
 * Hi Zayed,
    I’m new on wordpress; i download the plugin, i installed it and I 
   changed the colors of my category, but I don’t understand where i have to insert
   the following code: <?php $categories = get_the_category(); $separator = ”; $
   output = ”; if($categories){ foreach($categories as $category) { $rl_category_color
   = rl_color($category->cat_ID); $output .= ‘<div class=”featured-cat” style=”color:’.
   $rl_category_color.’;”>’.$category->cat_name.'</div>’.$separator; } echo trim(
   $output, $separator); } ?> Thanks in advance.
 *  Plugin Contributor [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * (@zayedbaloch)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822699)
 * Hi [@gabry75](https://wordpress.org/support/users/gabry75/)
 * When you want to show the categories name with the color, just paste the following
   code on your index.php, page.php or single.php file.
 *     ```
       <?php
           $categories = get_the_category();
           $separator = ' / ';
           $output = '';
           if($categories){
               foreach($categories as $category) {
                       $rl_category_color = rl_color($category->cat_ID);
                   $output .= '<a href="'.get_category_link( $category->term_id ).'" style="color:'.$rl_category_color.';">'.$category->cat_name.'</a>'.$separator;
               }
           echo trim($output, $separator);
           }
       ?>
       ```
   
 * If you need I will help to implement this as your website. Please send me a email
   on zayedbaloch(at)gmail(dot)com or share your website link.

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

The topic ‘Where to insert the code?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/category-color_aea56e.svg)
 * [Category Color](https://wordpress.org/plugins/category-color/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/category-color/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/category-color/)
 * [Active Topics](https://wordpress.org/support/plugin/category-color/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/category-color/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/category-color/reviews/)

## Tags

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

 * 13 replies
 * 7 participants
 * Last reply from: [Zayed Baloch](https://wordpress.org/support/users/zayedbaloch/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/where-to-insert-the-code-1/#post-5822699)
 * Status: resolved