Title: shortcodes display raw shortcode text
Last modified: March 26, 2018

---

# shortcodes display raw shortcode text

 *  [apb1963](https://wordpress.org/support/users/apb1963/)
 * (@apb1963)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/shortcodes-display-raw-shortcode-text/)
 * I’m trying to follow this article as best I can:
    // [http://www.wpbeginner.com/wp-tutorials/how-to-display-category-descriptions-in-wordpress/](http://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');
       ```
   
    -  This topic was modified 8 years, 1 month ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fshortcodes-display-raw-shortcode-text%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 1 month ago](https://wordpress.org/support/topic/shortcodes-display-raw-shortcode-text/#post-10116843)
 * `if ( ! empty( ) ) {`
 * that’s not valid. empty() requires a paraemeter
 *  [Oscprofessionals](https://wordpress.org/support/users/magentomaster/)
 * (@magentomaster)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/shortcodes-display-raw-shortcode-text/#post-10122543)
 * Hello apb1963,
    Below given is the correct code you should use that:-
 *     ```
       function wpb_catlist_desc() {
       $sring = '<ul>';
       $catlist = get_terms( 'category' );
       if ( ! empty( $catlist ) ) {
         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');
       ```
   
 * Then if you want to display it on any pages or post then use this [wpb_categories]
   or else use this echo do_shortcode(‘[wpb_categories]’);
    -  This reply was modified 8 years, 1 month ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [apb1963](https://wordpress.org/support/users/apb1963/)
 * (@apb1963)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/shortcodes-display-raw-shortcode-text/#post-10127150)
 * Thanks for responding, but as far as I can tell your code is identical to mine
   with the exception that you have a typo in your string, namely
 *     ```
       ,em>'
   
       $string .= ',em>'. $item->description . '</em> </li>';
       ```
   
 * The missing parameter for the empty() function was due to a missing backslash
   in my bash script. I already fixed that minor issue but I get the same results.
   Something else is wrong.
    -  This reply was modified 8 years, 1 month ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘shortcodes display raw shortcode text’ is closed to new replies.

## Tags

 * [Short Code](https://wordpress.org/support/topic-tag/short-code/)
 * [wp-cli](https://wordpress.org/support/topic-tag/wp-cli/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [apb1963](https://wordpress.org/support/users/apb1963/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/shortcodes-display-raw-shortcode-text/#post-10127150)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
