WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – John P Bloch Dec 24 '12 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... – John P Bloch Dec 24 '12 at 19:19
Yup forgot to paste the <?php } ?> ;-) thanks ... – Gab Dec 24 '12 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 Dec 24 '12 at 19:25
Correct. That is the expected behavior. This is because the loop only has the one post to loop through. – John P Bloch Dec 24 '12 at 19:26
up vote 1 down vote accepted

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

the links should have enough examples to get you started.

share|improve this answer
Thank you very much! – Gab Dec 24 '12 at 21:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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