I created a custom shortcode from my child theme's functions.php, And I want that shortcode to display in Post Category Description. But it's not working.
Do you guys have an idea on how to enable display of shortcodes in post category description?
Just correct me if I'm wrong.
Thanks!
This question already has an answer here: How get a shortcode working in category description (1 answer) Closed 6 years ago.I created a custom shortcode from my child theme's functions.php, And I want that shortcode to display in Post Category Description. But it's not working.
Do you guys have an idea on how to enable display of shortcodes in post category description?
Just correct me if I'm wrong.
Thanks!
I found the answer to my own question.
add_filter( 'term_description', 'shortcode_unautop' );
add_filter( 'term_description', 'do_shortcode' );
remove_filter( 'pre_term_description', 'wp_filter_kses' );
I just added those line of codes into the Child theme's function.php.
Thanks to this post: How to get a shortcode working in category description
I am not sure what kind of code is using in your theme. I am sharing the code for idea.
$cat_desc = category_description();
echo do_shortcode( $cat_desc );
category_description() function is getting the a category description. do_shortcode() function is searching the content for shortcodes and filter shortcodes through their hooks.
I have no idea about Divi theme but I got a filter. You try this code
add_filter( "category_description", "wse_parse_shortcode" );
function wse_parse_shortcode( $value ) {
return do_shortcode( $value );
}
category_description filter is defined in sanitize_term_field function