Support » Themes and Templates » ALL pages and posts using index template! 404 errors not getting called!

  • Resolved beefern


    Greetings all,

    I’m rather savvy at WordPress, I swear. I’ve never seen this before, and yes, I’ve re-installed 5 times with fresh databases, and tried all kinds of things.

    This is definitely an issue with my template. You see, whenever I load a post or page, they are getting loaded with the index.php template file instead of single.php or page.php … I should mention this template is using a custom post type for product listings, along with custom taxonomies (tags/categories) for those custom posts. ALL custom items are working fine!

    Has this ever happened to anyone???

    For example, I load my site and it does not show the propert content. It simply shows the index.php template file.

    In addition, if I enter or other non-existing URLs, well, the 404 page/error is not getting displayed! Instead, WordPress is simply accepting it as a real URL and once again showing the index.php template.

    And yes, I definitely have a page.php and single.php there…

    Thanks ahead of time for any help!

Viewing 14 replies - 1 through 14 (of 14 total)
  • In your pages, did you choose the correct page template for the correct page in your page settings? This can sometimes fix this issue, but if it doesn’t you can send me your theme and I could take a look at it.

    As for 404 I think you need to edit your .htaccess file so that it whenever there is a 404 error it would display the correct 404 page. I found a nice tutorial for .htaccess here.

    @ziv thanks for your suggestions! However its definitely not the issue as I’m following the Template Hierarchy which should work fine after WordPress 3.1 if I understand correctly.

    Ohh I understand. Which theme are you using?

    Custom theme, and its worked fine on other sites without custom posts enabled. Just not sure what is causing this unique issue.

    Alright, I am not an expert on conditionals / Template Hierarchy so I can’t really help sorry 🙁

    No worries mate. If anyone else might offer suggestions it would be greatly appreciated.

    Can you cend me the link of website.

    I guess you must check by using default permalink structure first.

    Sure here is the custom post example:

    And here is the normal post example:

    Please notice that the normal post does not work properly (it simply displays the index.php template instead of using the page.php template).

    Also, you can type absolutely anything and WordPress will accept it instead of delivering a 404 error:

    Thanks for any suggestions!

    The error where wordpress displays index.php instead of page.php usually occurs when you don’t have a page.php. Can you double check that you have your page.php setup correctly.

    I did a quick Google and found some php code that should be in page.php. It looks like this:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
      <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
        <div style="clear:both"></div>
    <?php endwhile; ?>
    <?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php get_search_form(); ?>
    <?php endif; ?>

    Do you have the same thing?

    @ziv, yes I do have a page.php template file with that code, just double checked again to be sure too.

    Even if I create a file called page-about.php it is still not recognized, and the About page reverts to the index.php template.

    However, interestingly, page-home.php does work fine for the homepage template. If I delete page-home.php it uses index.php for the homepage layout.

    If I switch to the default Twenty Eleven theme, I can view my normal pages just fine (but custom posts don’t show up, of course).

    I’m starting to think this is a bug in the WP 3.3.2 release unless someone knows what is causing this =\

    I guess you must check by using default permalink structure also I would like to know “ or other non-existing URLs, well, the 404 page/error is not getting displayed!” which page u see is it still index.php.

    For URLs that SHOULD be displaying the 404 template/error, yes, you are correct, the system is simply using the index.php template file and accepting ANY URL possible. This whole situation is very bizarre and I’ve never seen anything like it.

    Can some of the WP staff maybe look into this?

    Finally figured this out folks!

    I had one snippet in functions.php that was using a custom taxonomy called ‘year’ which is a reserved term.

    Strangely, it still worked fine and loaded with my custom post types, but made the default WP pages and posts stop loading properly. Very bizarre, but a lesson in watching out for reserved terms whenever customizing WordPress!

    Thanks for all the help.

    Glad you got it fixed!! I will watch out for this in the next theme I create 🙂

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘ALL pages and posts using index template! 404 errors not getting called!’ is closed to new replies.