WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] ALL pages and posts using index template! 404 errors not getting called! (15 posts)

  1. beefern
    Member
    Posted 2 years ago #

    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 example.com/about/ and it does not show the propert content. It simply shows the index.php template file.

    In addition, if I enter example.com/24ytoahg23oa4yh/ 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!

  2. Ziv
    Member
    Posted 2 years ago #

    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.

  3. beefern
    Member
    Posted 2 years ago #

    @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.

  4. Ziv
    Member
    Posted 2 years ago #

    Ohh I understand. Which theme are you using?

  5. beefern
    Member
    Posted 2 years ago #

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

  6. Ziv
    Member
    Posted 2 years ago #

    Alright, I am not an expert on conditionals / Template Hierarchy so I can't really help sorry :(

  7. beefern
    Member
    Posted 2 years ago #

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

  8. jeevank
    Member
    Posted 2 years ago #

    Can you cend me the link of website.

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

  9. beefern
    Member
    Posted 2 years ago #

    Sure here is the custom post example:

    http://www.raiyai.com/property/mooks-residence/

    And here is the normal post example:

    http://www.raiyai.com/about/
    http://www.raiyai.com/submit/

    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:

    http://www.raiyai.com/e924th298hweg098weh029ht/

    Thanks for any suggestions!

  10. Ziv
    Member
    Posted 2 years ago #

    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?

  11. beefern
    Member
    Posted 2 years ago #

    @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 =\

  12. gizmofreak
    Member
    Posted 2 years ago #

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

  13. beefern
    Member
    Posted 2 years ago #

    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?

  14. beefern
    Member
    Posted 2 years ago #

    Finally figured this out folks!

    http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

    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.

  15. Ziv
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic