2

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

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

  • It looks correct. But wordpress is loading the wrong page. Maybe it's a 404? Do you have a 404 setup? One way to solve this issue, is to find out what page template is loading. Just add some text to each template you have to see which one is loading wrong. Have you taken a look at the template hierarchy? codex.wordpress.org/images/1/18/Template_Hierarchy.png – gdaniel Feb 24 '14 at 22:31
  • the default pape.php is what seems to be loading. the other custom pages work fine. – user12920 Feb 24 '14 at 23:45
2

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( "\n\n<!-- ".__( 'Template file: %s', 'nvLangScope' )." -->\n\n", '/'.$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.

  • Nope. There is just something about this page that just does not want to work. I think Im going to try and just delete the page and create a new one, see if maybe that works.. so strange.. – user12920 Feb 25 '14 at 0:12
  • Thank you everybody for your various suggestions. I appreciate the help. I have fixed the problem, simply deleting the page (in wordpress) and just creating a new one seems to have fixed the problem. Not sure why I didn't think of that sooner and extra not sure why this even happened.. oh well! haha – user12920 Feb 25 '14 at 0:15
  • +1 to Matt for the nice function... I've always been adding the html comment filename to the top of my templates manually at template creation. – zipzit Jan 21 '15 at 6:43
0

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!

  • Checked. Its set to recent post. I havent messed with this setting at all. – user12920 Feb 25 '14 at 0:08
0

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.

  • It was set to true, but setting it to false doesnt make a difference. – user12920 Feb 25 '14 at 0:08
0

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:\xampp\htdocs\wordpress\wp-content\themes\tema2014\page-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

-1

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.

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.