Title: [Plugin: WP Most Popular] Multiple post types?
Last modified: August 20, 2016

---

# [Plugin: WP Most Popular] Multiple post types?

 *  [Simon Blackbourn](https://wordpress.org/support/users/lumpysimon/)
 * (@lumpysimon)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-multiple-post-types/)
 * Hi
 * Great plugin thanks and really well-written too.
 * I have a feature request: would it be possible to be able pass in an array of
   post types to the `wmp_get_popular` function? That way I could then show the 
   most popular items from my whole website, at the moment I’m limited to one post
   type at a time.
 * Thanks!
    Simon
 * [http://wordpress.org/extend/plugins/wp-most-popular/](http://wordpress.org/extend/plugins/wp-most-popular/)

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

 *  [Mindshare Labs, Inc.](https://wordpress.org/support/users/mindshare/)
 * (@mindshare)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-multiple-post-types/#post-2542939)
 * I’d like this too.
 *  [Mindshare Labs, Inc.](https://wordpress.org/support/users/mindshare/)
 * (@mindshare)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-multiple-post-types/#post-2542940)
 * This code <strike>should</strike> **doesn’t** work for multiple post types – 
   use the code below instead:
 *     ```
       <ul>
       <?php
       $my_post_type_1 = wmp_get_popular(array('limit' => 10, 'post_type' => 'my_post_type_1 ', 'range' => 'all_time'));
       $my_post_type_2 = wmp_get_popular(array('limit' => 10, 'post_type' => 'my_post_type_2', 'range' => 'all_time'));
   
       $all_types = array_merge($my_post_type_1 , $my_post_type_2);
       if(count($all_types) > 0) : foreach($all_types as $post) : setup_postdata($post); ?>
           <li><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
       <?php endforeach; endif; ?>
       </ul>
       ```
   
 *  [Mindshare Labs, Inc.](https://wordpress.org/support/users/mindshare/)
 * (@mindshare)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-multiple-post-types/#post-2542941)
 * Actually, I just tested my code and it didn’t work. I had to add in some type
   casting… here’s the updated code I’m using on my site and it works:
 *     ```
       <ul>
       <?php
       $documents = wmp_get_popular(array('limit' => 10, 'post_type' => 'document', 'range' => 'all_time'));
       $opinions = wmp_get_popular(array('limit' => 10, 'post_type' => 'opinion', 'range' => 'all_time'));
       $articles = wmp_get_popular(array('limit' => 10, 'post_type' => 'article', 'range' => 'all_time'));
       $videos = wmp_get_popular(array('limit' => 10, 'post_type' => 'video', 'range' => 'all_time'));
       $audios = wmp_get_popular(array('limit' => 10, 'post_type' => 'audio', 'range' => 'all_time'));
   
       $documents = (object) array_merge((array) $documents, (array) $opinions, (array) $articles, (array) $videos, (array) $audios);
       global $post;
       if(count($documents) > 0) : foreach($documents as $post) : setup_postdata($post); ?>
           <li class="<?=get_post_type($post->ID)?>">
       		<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
       	</li>
       <?php endforeach; endif; ?>
       </ul>
       ```
   
 *  Plugin Author [MattGeri](https://wordpress.org/support/users/mattgeri/)
 * (@mattgeri)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-multiple-post-types/#post-2542951)
 * Thanks guys!
 * I will include this in the next version coming out this weekend.
 * Matt

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

The topic ‘[Plugin: WP Most Popular] Multiple post types?’ is closed to new replies.

 * ![](https://ps.w.org/wp-most-popular/assets/icon.svg?rev=1861383)
 * [WP Most Popular](https://wordpress.org/plugins/wp-most-popular/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-most-popular/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-most-popular/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-most-popular/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-most-popular/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-most-popular/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [MattGeri](https://wordpress.org/support/users/mattgeri/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-multiple-post-types/#post-2542951)
 * Status: not resolved