Title: [Plugin: WordPress.com Popular Posts] Could you Add a Shortcode?
Last modified: August 19, 2016

---

# [Plugin: WordPress.com Popular Posts] Could you Add a Shortcode?

 *  Resolved [Tim Nicholson](https://wordpress.org/support/users/timnicholson/)
 * (@timnicholson)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-popular-posts-could-you-add-a-shortcode/)
 * Would you be willing to add a shortcode for us to be able to display our most
   popular posts in a page? This would allow us to easily create a dedicated “Top
   10 Posts” page or whatever.
 * Here’s the code to add to your plugin:
 *     ```
       function WPPP_shortcode_popular_posts( $user_args = '' ) {
       	$wppp = new WPPP();
               $args = shortcode_atts( $wppp->defaults, $user_args );
       	$wppp->widget( $args );
       }
       add_shortcode('wp_popular_posts', 'WPPP_shortcode_popular_posts');
       ```
   
 * It creates a simple function similar to your direct embed function for sidebars,
   but the arguments for shortcodes are in a different format, so you have to use
   a different parse function: shortcode_atts().
 * For users, here is an example that displays a nice top 10 list, complete with
   title, number of views, excerpt, and its cached for performance. Just be SURE
   you paste this into the WP page in HTML or the editor will screw up the HTML 
   formatting in the format= parameter.
 * `[wp_popular_posts title='' number=10 list_tag=ol format='<a href="%post_permalink%"
   title="%post_title_attribute%">%post_title%</a> (%post_views% views)<p>%post_excerpt%
   </p>' excerpt_length=200 cachename=popular-posts-page]`
 * Feel free to add the magic_number= parameter if you aren’t getting a full 10 
   posts returned.

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

 *  [frasten](https://wordpress.org/support/users/frasten/)
 * (@frasten)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-popular-posts-could-you-add-a-shortcode/#post-1359014)
 * Many thanks for your contribution! I will sure add this feature in the next version
   of wppp! 🙂
 *  Thread Starter [Tim Nicholson](https://wordpress.org/support/users/timnicholson/)
 * (@timnicholson)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-popular-posts-could-you-add-a-shortcode/#post-1359041)
 * frasten, that’s great! I always think its best to get any enhancements rolled
   into the original plugin, as long as they are of general value to other users.
   That way we don’t have to worry about upgrading when a new version comes out.
 * BTW, kudos to you for your well-written code that this was so easy to do and 
   also for including the cache feature.
 *  [djjuvan](https://wordpress.org/support/users/djjuvan/)
 * (@djjuvan)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-popular-posts-could-you-add-a-shortcode/#post-1359333)
 * What about thumbnail for popular posts? I’m searching any way to get thumbnail
   next to popular posts in widget :\

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

The topic ‘[Plugin: WordPress.com Popular Posts] Could you Add a Shortcode?’ is 
closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [djjuvan](https://wordpress.org/support/users/djjuvan/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-wordpresscom-popular-posts-could-you-add-a-shortcode/#post-1359333)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
