0

The posts on my custom theme are using the index.php file instead of single.php _ I have looked through at least 10 questions on SO_ although many of them are very old _

Some answers said that if the WP loop isn't set up in single.php then it won't be called _ BUT my single.php file does contain the loop _

<?php get_header(); ?>

    <div class="container fadeIn" id="perimeter">
        <section id="page">
           <div class="row">
               <div class="col-12">
                    <div class="divPad">
                        <?php if(have_posts()) : ?>
                            <?php while(have_posts()) : the_post(); ?>
                                <?php the_content(); ?>
                            <?php endwhile; ?>
                        <?php else : ?>
                            <?php echo wpautop('Sorry, no posts were found'); ?>
                        <?php endif; ?>                    
                    </div>
                </div>       
           </div>
        </section>

        <div class="horizBuffer2"></div>
    </div><!-- /#perimeter -->

<?php get_footer(); ?>

One answer appears on several questions and judging from the spelling and other idiosyncrasies has clearly been copy/pasted _ It says something about changing permalinks in the WP dashboard Settings section _ but it doesn't explain clearly what should be changed _

IMPORTANT: This custom theme does NOT have a blogroll page _ All posts are sent to different pages via their categories _

Thanks in advance to anyone who can get my posts to display on single.php

  • 1
    Are you sure that the template being used is indeed index.php ? – Sally CJ Aug 13 at 22:46
  • hi Sally _ very happy to see you cos you helped me out once before with with a bootstrap 4 modal : ) – inputforcolor Aug 13 at 22:55
  • this is the URL to a post which I want to show up in the single.php so that I can style the page >>> lilyrigby.com/index.php/2019/08/12/hughie-odonoghue – inputforcolor Aug 13 at 22:55
  • 1
    Yeah, I'm glad to see you've got it sorted already. :) – Sally CJ Aug 13 at 23:23
  • 1
    Good to see you again @SallyCJ _ thanks for showing up : ) – inputforcolor Aug 13 at 23:24
0

single.php will only display a single post on the other hand index.php is the default template that displays everything including posts, post, page, categories, and tags only if specific template file is not present.

  • thanks for your reply @DenIsahac _ I only want a single post to be displayed _ from clicking on the 'read more' button / link after displaying an excerpt – inputforcolor Aug 13 at 22:58
  • 2
    Based on the provided URL above the post is actually being served from single.php If you inspect the elements using browser dev tools, and hover around the <body> tag there's a bunch of classes applied and two of those are single and single-post that means it is using the single.php – Den Isahac Aug 13 at 23:09
  • you are correct Den _ it is single _ I added a <span> 'THIS IS SINGLE' and it is displayed – inputforcolor Aug 13 at 23:16
  • 2
    Template files aren't directly accessible via URL; i.e. front-page.php, page.php, single.php. Even though you're seeing index.php on the URL that doesn't mean it is using index.php template file -- it could be the other templates. It is how WP handles URL rewrites. If you don't want to see the index.php on the URL and want a clean and readable one go to Appearance > Permalinks > Common Settings and from there select the desired permalink structure. – Den Isahac Aug 13 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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