Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a simple site where I want to handle blog posts with a custom page template.

So I've created a new page called blog with a document url value of "blog". My custom php template page was created with

/*
Template Name: Blog Page
*/

and this "blog page" has been assigned to my new wordpress page.

All that works as expected until I try to view the WP page. Instead of seeing the custom HTML I would expect I instead see the standard wordpress posts listing page.

To clarify: the custom template page I made is definitely not being presented to the screen even though no url redirect has occurred and we are apparently viewing my "blog" page. I added unique HTML markup to my custom template so I would be able to clearly identify it when it shows and that isn't appearing.

I've made sure in Settings/Reading that the "Posts page" dropdown is set to my custom page but still no luck.

Can someone tell me whats going wrong here=? I assume a page url name of "blog" is maybe not allowed as its reserved? Although WP doesn't complain about it at any point.

share|improve this question
    
In your theme folder create a template called home.php and copy the contents of your blog page (apart from the template header) into that and see if the problem exists, WP uses home.php as the default template for posts, if that doesn't exist then it uses index.php, it doesn't look to use page.php or custom templates. –  Gareth Gillman May 28 at 14:57
    
@GarethGillman, adding home.php does work. However I'm a little surprised by wordpress's handling of the situation of a user creating a page called "blog" and it just in effect ignoring it. Is that really the best WP can do in terms of user friendliness? Is there no other way to more elegantly handle the solution I want with my code residing in the custom template assigned to my new page document? –  AdamJones May 28 at 15:08
    
It's because as soon as you set a page to be 'posts', the page becomes a totally different entity. On the WP codex look for the Template Heirarchy which will help you understand how WP looks for templates. –  Gareth Gillman May 28 at 15:11
    
My question is more about the fact you can't set a page to be called "blog". This seems to be the case irrelevant of the page has been defined as the post page (via settings/reading) or not. –  AdamJones May 28 at 17:04
    
I hadn't come across when you call it blog, WP doesn't have blog set as a reserved term though - codex.wordpress.org/Function_Reference/… –  Gareth Gillman May 28 at 17:10

1 Answer 1

up vote 0 down vote accepted

Even if you specify a static page for your Posts page in Settings > Reading, Wordpress will still use index.php to construct the post-listing page. I don't think it is possible to override this using a custom page template.

share|improve this answer
    
Hi @Ben Stevens. It just surprises me how ungracefully wordpress seems to handle a page being called blog. Even if thats all I do, ie not making changes to Settings/Reading. –  AdamJones May 28 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.