• My main menu has a page menu item. When I click on that menu item, the correct URL gets displayed in the browser. But the index page of the site gets displayed instead of the template I have specified for that page.

    I have a custom template assigned to the page. I also have a page.php defined. The way I understand it is that if WordPress can’t find that custom template, it will try to use page.php and then index.php.

    Both page.php and the custom template php file are present.

    Does anyone have an idea of what I could try to fix this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • If this Page is set as the Blog page (aka the ‘Posts page’ in Admin->Settings->Reading), then it will ignore any template and use index.php instead, per the Codex:

    Also, any Template assigned the Page will be ignored and the theme’s index.php (or home.php if it exists) will control the display of the posts.

    This is a quote from this article:

    http://codex.wordpress.org/Settings_Reading_SubPanel

    Try creating/modifying home.php.

    Thread Starter kevinsikora

    (@kevinsikora)

    No, the page I am using is not set as the Blog page in Admin->Settings->Reading. The page I am trying to display is not used as the (main/home/index) “page.”

    That was my best guess. Sorry I don’t have more suggestions.

    Thread Starter kevinsikora

    (@kevinsikora)

    My .htaccess file has the following:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    From what I understand, that should be correct. The WordPress site was listing this as the correct setting.

    For functions, the only that could affect me would be this one:


    function get_all_posts_mp($query)
    {
    if(is_home() && $query->is_main_query())
    {
    $query->set('post_type', array('events')); // add custom post types into the array

    $query->set('posts_per_page', 4);
    }
    }
    add_filter('pre_get_posts', 'get_all_posts_mp');

    That code should only affect the main/index page of the site. Even if I remove that code, the page menu item still won’t work for me.

    The .htaccess file is being used because if I make modifications to it, I can see them happening with my site.

    I display my menu with the following code:


    <?php
    $menu_code = wp_nav_menu(array('echo' => false));
    $menu_code = str_replace(array("\n"), "", $menu_code);
    print($menu_code);
    ?>

    That code prints out the following:


    <div class="menu-main-container">
    <ul id="menu-main" class="menu">
    <li id="menu-item-65" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item menu-item-home menu-item-65">Home
    <li id="menu-item-66" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-66">Events
    <li id="menu-item-223" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-223">Contact

    </div>

    Thread Starter kevinsikora

    (@kevinsikora)

    For plugins, I have WPML installed and Types. When I disable types, the site completely stops working.

    These two plugins are required for my site.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Index page displayed instead of page template’ is closed to new replies.