Custom page template not working

I followed this tutorial for the page specific template — http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

Created a page through wordpress admin panel – Blog Page URL like — http://localhost/wordpress/blog-page/ and set template to my template “Swapnesh” from the admin panel itself.

Read More

Created my specific page template as page-blog-page.php containing following code —

<?php

/*
Template Name: Swapnesh
*/


get_header(); ?>

        <div id="primary">
            <div id="contentabc" style="border:7px solid red;">

                <?php while ( have_posts() ) : the_post(); ?>

                    <?php get_template_part( 'content', 'page' ); ?>

                    <?php comments_template( '', true ); ?>

                <?php endwhile; // end of the loop. ?>

            </div><!-- #content -->

            <?php get_sidebar(); ?>

        </div><!-- #primary -->

<?php get_footer(); ?>

Now when im navigating to http://mysite/wordpress/blog-page/ im not getting that border so that i can proceed further, let me know what im doing wrong.

note– Under “Reading Settings” mu post page selection was “Blog Page” when i dis select this option its showing me the red border but no posts then 🙁

Related posts

Leave a Reply

2 comments

  1. I think you’re muddling up the Template Hierarchy, so make sure to start by reading that.

    page-blog-page.php is for a page with the slug “blog-page.” If you’re using a page template, then you should name it something outside of the template hierarchy-reserved name spaces (e.g. page-{slug}, etc.) such as template-swapnesh.php.

    Also, WordPress has the blog page specifically built into the template hierarchy: home.php. You should be using that instead of page-blog-page.php. As you’ll see in the template hierarchy graphic, the “Posts Page” never looks for a custom page template, it goes straight to home.php and falls back to index.php.

  2. A safe way to create page templates is to copy an existing template from your theme folder, rename the file, rename the template within the comments and modify the code as needed. Often they have more code than just get_header(); and get_footer(); which you may need for your theme to render properly.