I have a custom post type of Textorial with necessary template files:

  1. textorial-type.php
  2. single-textorial.php
  3. content-textorial.php

The idea is to have a custom layout for the post type and use infinite-scroll to pull them in. That's why I'm using content.php. I got the infinite-scroll set up,and succesfully tested with regular posts. But when pulling custom post type in on index.php:

<div id="content">
    while (have_posts()) : the_post();
        get_template_part( 'content', 'textorial' );                    

... nothing shows up. Also no errors. But the single-textorial.php is using the same method and its content is showing. Any ideas?


on front-page.php:

<?php $args = array('post_type' => 'textorial');
                $query = new WP_Query( $args );
                while (have_posts() ) : the_post();
                    get_template_part( 'content', 'textorial' );

But now only regular posts show up.

  • Did you use pre_get_posts to set your custom post type in the main query. Also, what is texorial-type.php Commented Jan 28, 2015 at 12:15
  • I don't follow you when say main query, you are looking at the main query. Doesn't it know to pick up textorial post-type without it? textorial-type.php is the file where I declare the custom post type and control its parameters.
    – Laniakea
    Commented Jan 28, 2015 at 12:34
  • Ha, that confused me, so textorial-type.php is like a functions.php file. Remember, custom post types are excluded from the main query Commented Jan 28, 2015 at 12:37
  • Yeah, I keep them separate for code reading purposes. I tried query know, please see update.
    – Laniakea
    Commented Jan 28, 2015 at 12:48
  • On which specific page/template are you trying this Commented Jan 28, 2015 at 12:52

1 Answer 1


You have a couple of issues with your code.

  • You have to set your loop to your custom query. As it stands, it is set to the main query

  • You must always reset postdata with all instances of WP_Query

Your code should be something like this

<?php $args = array('post_type' => 'textorial');
$query = new WP_Query( $args );
while ($query->have_posts() ) : $query->the_post();

    get_template_part( 'content', 'textorial' );

wp_reset_postdata(); ?>
  • Yeah, custom posts are now showing up. Thank you for your input.
    – Laniakea
    Commented Jan 28, 2015 at 13:59
  • Glad it worked. Enjoy :-) Commented Jan 28, 2015 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.