Title: Convert function to shortcode
Last modified: August 22, 2016

---

# Convert function to shortcode

 *  [dolliv](https://wordpress.org/support/users/dolliv/)
 * (@dolliv)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/convert-function-to-shortcode/)
 * Hello
 * I was wondering how I could convert the following code in a shortcode, so that
   I can use it in my sidebar and posts. Anyone that can help?
 * Thanks in advance!
 *     ```
       <?php
       $result = count_users();
       echo 'There are ', $result['total_users'], ' total users';
       foreach($result['avail_roles'] as $role => $count)
           echo ', ', $count, ' are ', $role, 's';
       echo '.';
       ?>
       ```
   

The topic ‘Convert function to shortcode’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [dolliv](https://wordpress.org/support/users/dolliv/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/convert-function-to-shortcode/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
