Select Page

I just added title and descriptions to my category pages with these simple steps.

Step 1 – Create category.php file

Copy index.php file and paste it as category.php if you dont’ have one in your WordPress theme. I am using DIVI child theme so there was no category.php file in my child theme when I looked it via “theme editor” under Appearance option in Dashboard. You can create a new file by FTP or directly going to file explorer section in your server’s control panel.

Here is a screenshot of me copying index.php from main theme and creating a category.php file inside my Divi’s child theme folder through server’s control panel file explorer:


Step 2 – Open it inside an editor

Now open the category.php in any editor and add following lines of PHP codes and save it.

<div class="left-area__category-top">
    <?php 
        the_archive_title( '<h1 class="category-title">', '</h1>' ); 
        the_archive_description(); 
    ?>
</div>

Here is a screenshot of me doing the same for my website:


Step 3 – Style elements

Now you can style your h1 and p tag inside the main CSS class selector ( you can use any class of your choice ) and add it in your theme’s CSS.

.left-area__category-top{
    margin-bottom:20px;
}
.left-area__category-top h1{
    font-size:50px;
    color:#222;
}
.left-area__category-top p{
    color:#333;
}

Result

Here is a screenshot of the result I got after applying the above steps.

Demo link – https://webdevpuneet.com/category/freelance-tips/