Title: Split List by Post Type
Last modified: August 21, 2016

---

# Split List by Post Type

 *  [greenfireco](https://wordpress.org/support/users/greenfireco/)
 * (@greenfireco)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/split-list-by-post-type/)
 * I used a code from before to display my favorites.
 * I replaced:
 *     ```
       query_posts(array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page));
       while ( have_posts() ) : the_post();
          echo "<li><a href='".get_permalink()."' title='". get_the_title() ."'>" . get_the_title() . "</a> ";
          wpfp_remove_favorite_link(get_the_ID());
          echo "</li>";
       endwhile;
       ```
   
 * With:
 *     ```
       foreach ($favorite_post_ids as $post_id) {
           $p = get_post($post_id);
           echo "<li>";
           echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> ";
           wpfp_remove_favorite_link($post_id);
           echo "</li>";
       }
       ```
   
 * But my question is, I want to separate the lists by different Custom Post Types…
   so how can I make this code only show favorites from one specific post type.
 * Then I figure I would duplicate it over again for the other Custom Post Types.
 * [https://wordpress.org/plugins/wp-favorite-posts/](https://wordpress.org/plugins/wp-favorite-posts/)

Viewing 1 replies (of 1 total)

 *  [Joshua David Nelson](https://wordpress.org/support/users/joshuadnelson/)
 * (@joshuadnelson)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/split-list-by-post-type/#post-4815351)
 * Hey there,
 * I was looking at something similar, check out this reply to another support thread:
   [http://wordpress.org/support/topic/favorite-in-custom-post-type-not-working?replies=10#post-5500983](http://wordpress.org/support/topic/favorite-in-custom-post-type-not-working?replies=10#post-5500983)
 * You should always use WP_Query instead of query_posts, and just change the `$
   qry['post_type'] = array('post','page',);` line in that the code linked above
   to your specific post type.
 * Hope that helps!
    Joshua

Viewing 1 replies (of 1 total)

The topic ‘Split List by Post Type’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-favorite-posts.svg)
 * [WP Favorite Posts](https://wordpress.org/plugins/wp-favorite-posts/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-favorite-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-favorite-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-favorite-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-favorite-posts/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Joshua David Nelson](https://wordpress.org/support/users/joshuadnelson/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/split-list-by-post-type/#post-4815351)
 * Status: not resolved