Title: Adding custom posts to The Loop
Last modified: August 31, 2016

---

# Adding custom posts to The Loop

 *  Resolved [Ghostwise_](https://wordpress.org/support/users/ghostwise_/)
 * (@ghostwise_)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-posts-to-the-loop/)
 * Hello,
 * Probably a silly question since I’m a newcomer to WordPress…
 * I have a custom posts type called post_news
 * The index.php of the site I’m trying to build displays the usual list of recent
   posts with what seems to be the usual bit (“The Loop”, apparently) :
 * `<?php if (have_posts()) : while (have_posts()) : the_post(); ?>`
 * I’m trying the have my custom post_news posts displayed along with the basic 
   posts in this loop.
 * My best try so far, in the function.php of the theme, produces no results :
 *     ```
       function add_news($query) {
         if ( !is_home() && $query->is_main_query() ) {
             $query->set('post_type', array( 'post', 'post_news' ) );
           }
         }
   
       add_action('pre_get_posts','add_news');
       ```
   
 * Any advice ? Thanks !
 * [https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Ghostwise_](https://wordpress.org/support/users/ghostwise_/)
 * (@ghostwise_)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-posts-to-the-loop/#post-7333970)
 * OK, found the issue in my if clause. Solved !

Viewing 1 replies (of 1 total)

The topic ‘Adding custom posts to The Loop’ is closed to new replies.

 * ![](https://ps.w.org/wck-custom-fields-and-custom-post-types-creator/assets/icon-
   256x256.png?rev=2257602)
 * [Custom Post Types and Custom Fields creator - WCK](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/)
 * [Active Topics](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Ghostwise_](https://wordpress.org/support/users/ghostwise_/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-posts-to-the-loop/#post-7333970)
 * Status: resolved