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.
Step 1
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)
Step 2
Open functions.php for editing.
Step 3
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
Step 5
Now you have your shortcode, within WordPress, Open Divi Theme Builder and select to edit the body template for All Category Pages
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.
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
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
This solution was developed and confirmed in WordPress 6.1.1 & Divi Theme 4.19.2 by windowssolved.com |
This 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. |
Everything is very open with a precise description of the challenges. It was truly informative. Your website is very helpful. Thank you for sharing!
Good write-up. I definitely appreciate this website. Continue the good work!
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.