I'm creating a WordPress theme for my portfolio and I would like to my single.php file to act just like the index.php. I need the single.php to show the entire loop but if I access single post's page it only shows the specific post not the full list of posts.

I'm using a one page design and I have to use i.e <?php echo($post->post_name) ?> on page load in order to load some AJAX and have some deeplinking, etc.

If I delete the single.php it also only shows the specific post not the full list of posts when using a http://www.example.com/postname URL. Deleting functions.php doesn't change anything about it.

Here is a simplified version of the index.php/single.php loop:

<?php get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if (has_post_format( 'image' )) { ?>
<?php } else if (has_post_format('chat')) { ?>
<?php } else if (has_post_format('gallery')) { ?>
<?php } else if (has_post_format('video')) { ?>
<?php } else { ?>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>

Many thanks for your time and help.

  • 2
    If you don't have a single.php, it (usually) does use index.php. Could you be more specific about what you're trying to accomplish? It sounds like you want the url for every post to instead show the main blog feed. Commented Dec 24, 2012 at 19:17
  • Also, you have an unclosed bracket in that code (closing the else statement). Not sure if that's just an oversight in pasting the code... Commented Dec 24, 2012 at 19:19
  • Yup forgot to paste the <?php } ?> ;-) thanks ...
    – Gab
    Commented Dec 24, 2012 at 19:21
  • It does use index.php but only shows the post of the that single post url. Not the all the posts. Just did the test with the Twenty Twelve theme and it does the same after renaming it's single.php file.
    – Gab
    Commented Dec 24, 2012 at 19:25
  • Correct. That is the expected behavior. This is because the loop only has the one post to loop through. Commented Dec 24, 2012 at 19:26

1 Answer 1


you could create a secondary loop using WP_Query()to get all posts;

the links should have enough examples to get you started.


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.