$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - How to enable custom Shortcodes in Post Category Description?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - How to enable custom Shortcodes in Post Category Description?

matteradmin8PV0评论
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!

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!

Share Improve this question asked Jan 30, 2019 at 9:08 Toto MemengToto Memeng 1136 bronze badges 0
Add a comment  | 

3 Answers 3

Reset to default 1

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

Post a comment

comment list (0)

  1. No comments so far