I dont get why this isnt working. I have a custom page template, page-politics.php. It should look similar to this page:
But its displaying this:
Ive double, triple checked that the right template is assigned to the right page.
I dont get why this isnt working. I have a custom page template, page-politics.php. It should look similar to this page:
But its displaying this:
Ive double, triple checked that the right template is assigned to the right page.
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.
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!
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.
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
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.