Page template not displaying

I dont get why this isnt working. I have a custom page template, page-politics.php. It should look similar to this page:

banking transaction page

Read More

But its displaying this:

campaign contribution page

Ive double, triple checked that the right template is assigned to the right page.

page settings for campaign office page

Related posts

5 comments

  1. This is less of an answer and more of a kind of troubleshooting aid… Add this function to your project (probably functions.php) and then call it from the top of every template file in your theme…

    /**
     * Outputs the name of the file as an HTML comment for easy-peesy troubleshooting.
     *
     * @param string $file This function should always be passed the value of __FILE__
     */
    function output_file_marker( $file )
    {
        // Strip out system path (keeping only site-root-relative path)
        $file = preg_replace( '|' . preg_quote( ABSPATH ) . '|', '', $file );
    
        // Output an HTML comment with the current template path
        printf( "nn<!-- ".__( 'Template file: %s', 'nvLangScope' )." -->nn", '/'.$file );
    }
    

    This will help you identify which template file is being loaded by outputting an HTML comment at the start of each template, and can help you solve a lot of weird “wrong template” problems.

    Second, try this…

    Set your Page Attribute > Template back to Default, then rename your template file according to the page number instead of the slug (you may also want to remove the template name… just in case). For example, if your problem page had a post id of 103, you would name the template file page-103.php

    If you want to keep the template as an admin-selectable override template, then use a different naming convention. I use override-description.php when a template should be admin selectable.

    Finally, make sure any and all plugins are disabled. Plugins can mess with templates by overriding them… this is particularly true of certain eCommerce packages.

  2. I don’t know if what’s showing up on that page are your posts or not, but you should check your settings to see whether or not that page is set as the “Posts” page in the “Reading” tab. If that’s set, it overrides the template and just loads index.php instead of your template.

    Best of luck!

  3. Check if you have registered a custom post type thats’ slug is ‘politics’ ('rewrite' => array('slug' => 'politics')). If you use a custom post type that has the same slug as one of your pages, it is likely that WordPress will show you the archive page of your cpt instead of the page in your menu. If you do not need the cpt’s archive you can set 'has_archive' => false for this custom post type.

    Flush your permalinks after modifying the rewrite rules.

  4. I tested your page on my local install, it works fine, but there is a error on the page in debug mode. here is your error, so maybe you can work from here as well

    Warning: number_format() expects parameter 1 to be double, string given in C:xampphtdocswordpresswp-contentthemestema2014page-test.php on line 39

    Agood point to note, when your busy designing a theme, set your debug to true in wp-config.php. this really helps a lot getting errors fixed

  5. It’s not on the side bar in some templates but, if you scroll down to the bottom of your page, under all that you have written, it appears at the bottom of that.

Comments are closed.