Solved – Display Category Descriptions in Divi for WordPress

Written by Windows Solved

December 7, 2022

Solved – Display Category Descriptions in Divi for WordPress

This Article will show you how to display WordPress category descriptions in your category pages built with Divi Theme Builder’s Visual Editor.

If your category pages don’t have any descriptions, that not affects your end user understanding of your site but it can also negatively affect your SEO rankings.

In searching for how to make this customization, we were unable to find a complete solution that worked. Many articles referred to modifying the files archives.php or categories.php. However, when we searched the Divi files, they don’t exist.

 We are assuming you have already created your categories within WordPress and set the category descriptions. We are also assuming you have already used Divi’s Theme Builder to create your body template for “All Category Pages”. If you have not done so yet, you should complete this before proceeding. 

  1. Step 1

  2. Using your favorite FTP program or  control panel file editor on your server, navigate to your folder wp-content/themes/Divi and locate functions.php. Make a backup of that file (in case you make a mistake and corrupt the file, like we did on the first attempt and accidently typed a character somewhere in the file that broke Divi Visual Editor and our Post edit function)

  1. Step 2

  2. Open functions.php for editing.

  1. Step 3

  2. For this step, we would like to thank David’s post on StackExchange  for providing the generic WordPress code to create a new shortcode for the category description. 
    At the end of the file functions.php, add the following code :

// Added to create category description shortcode
add_shortcode(‘cat_description’, ‘my_cat_description_shortcode’);
function my_cat_description_shortcode($atts){

$a = shortcode_atts( array(
‘id’ => 0,
), $atts );

return category_description($a[‘id’]);

}
// End Added to create category description shortcode

 

 

To display Category Descriptions in Divi, you will need to edit functions.php

Step 5

Now you have your shortcode, within WordPress, Open Divi Theme Builder and select to edit the body template for All Category Pages

To show category description short code in Divi, we now need to edit your All Category Pages template.

Step 6

Now you visual editor will open. Just below your title, add a new section, select Regular, the select the row with one large column (should be first in top left) and then choose to add Text to it.

To show the category description short code in Divi, we now need to add a new text row under the title.

Step 7

At this stage, your Visual Editor text bow should now be open. In text area, add the following code :

cat_description

and Save

Add the shortcode code to a text field within Divi to display the category description.

Step 8

When you save your Visual Editor, the category description will look to be missing. It is there but is just displaying as an empty field.

Close your Divi Visual Editor, and your category descriptions should now be showing

Category Descriptions now correctly display within in Divi Theme
This article is originally authoredThis solution was developed and confirmed in WordPress 6.1.1 & Divi Theme 4.19.2 by windowssolved.com
This is a copyright articleThis is an original article copyright to windowssolved.com
This article may be shared via link to this page.
You may not repost the content of this page, even with attribution without prior written permission.

3 Comments

  1. Anonymous

    Everything is very open with a precise description of the challenges. It was truly informative. Your website is very helpful. Thank you for sharing!

    Reply
  2. Anonymous

    Good write-up. I definitely appreciate this website. Continue the good work!

    Reply
  3. Anonymous

    Good post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. Its always useful to read content from other authors and practice something from their websites.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

If you have any questions or suggestions regarding the solutions to Microsoft Windows we have posted on our site, or would like is to publish and share one of your own solutions, feel free to get in contact with us.

If you are a site owner and have an original article that you are the copyright owner of and would like us to re-publish it on windowssolved.com, we can do so and provide you a free valuable backlink to your website as an attribution/credit. Contact us today.

Related Articles