shortcodes display raw shortcode text
-
I’m trying to follow this article as best I can:
// https://www.wpbeginner.com/wp-tutorials/how-to-display-category-descriptions-in-wordpress/However, I need to do everything from the wp-cli so I can’t follow the directions precisely but I did my best. In particular, I added the below code to a “storefront” child theme’s functions.php file I created for this purpose (although just this minute I learned about “site specific plugins” and I may decide to do it that way instead which I guess is beside the point.)
Unfortunately, short codes display the raw short code text rather than executing the function. I suspect I’m missing something like some kind of hook tie-in or something, but I don’t know what exactly. Some of the pages I’ve read hint strongly at this, but I was unable to translate to my specific situation. Thank you in advance!
function wpb_catlist_desc() { $string = '<ul>'; $catlist = get_terms( 'category' ); if ( ! empty( ) ) { foreach ( $catlist as $key => $item ) { $string .= '<li>'. $item->name . '<br />'; $string .= '<em>'. $item->description . '</em> </li>'; } } $string .= '</ul>'; return $string; } add_shortcode('wpb_categories', 'wpb_catlist_desc');
The page I need help with: [log in to see the link]
- The topic ‘shortcodes display raw shortcode text’ is closed to new replies.