I've created a custom post type: tutorials using generatewp.com generator and registered it with register_post_type().

I'm querying the list of tutorials in a custom page template like that:

<?php $query = new WP_Query('post_type=tutorial'); ?>
<?php if($query->have_posts()) : ?>
  <?php while($query->have_posts()): the_post(); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <p><?php the_excerpt(); ?></p>
  <?php endwhile(); ?>
<?php endif; ?>

To target single tutorial template I've created a file single-tutorial.php, placed a loop inside it, and fired the tutorial permalink in the browser.

The single-tutorial.php file is ommited from Template Hierarchy and goes directly to index.php.

The premalink is for example: http://example.com/tutorial/tutorial-name/.

index.php content is loaded instead of single-tutorial.php

Why is that? Any help very appreciated.

  • Have a look at this post and this post If this doesn't help, please post your code then for your custom post type Aug 31, 2014 at 8:47
  • My pleasure, glad those links were helpful. :-) Aug 31, 2014 at 9:12


Your Answer

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

Browse other questions tagged or ask your own question.