• Resolved toastedonions

    (@toastedonions)


    Hi there,
    I’ve been all over the Internet and asked a programmer I know who is fairly familiar with WordPress, and I still haven’t found a solution. After trying several ideas, I may have thoroughly messed up my code (in a way that renders all code ineffective without messing up the visitor’s view).

    Working on jonidaniels.lymelight-webs.com/blog

    I have header-blog.php that I’d like to put on just one template, called blog-page.php and named “Power-Tools.” “Power-Tools” does show up in the page template dropdown now. I created a page for the blog and gave it this template, and I went to Settings > Reading to make this page the posts page.

    At the same time, I tried attaching header-blog.php to blog-page.php but this is where I’m having difficulty. The template for the blog appears to be calling header.php no matter what I try:

    get_header( $blog );
    get_header(‘blog’);
    include(TEMPLATEPATH . ‘/header-blog.php’;
    get_header( $name = blog );
    include_once($_SERVER[“DOCUMENT_ROOT”] . “/wp-content/themes/jonidaniels/header-blog.php”);

    I didn’t expect some of these to work, but I was desperate 😉 Again, it’s possible that by now, after editing every page involved, I’ve farg’d up the code enough that every attempt is useless; but perhaps someone can point it out because I’ve been staring at this for so long. I’ll copy any necessary code into this post for you to view – just let me know.

    Really though that get_header( $blog ); would work, since it’s in the codex… Thanks in advance!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter toastedonions

    (@toastedonions)

    I even went out on a limb and tried get_header(“$blog”); but still no luck. Totally not seeing the problem =(

    Hmmm. Are you seeing the page as your front page? Are you using any caching? Have you cleared your browser cache?

    Thread Starter toastedonions

    (@toastedonions)

    I’ve cleared my cache each time I’ve reloaded. I also checked get_header(‘blog’); on two other computers. It is not set to be the front page and is not displaying as the front page either.

    This header should be loading on the blog-page.php template, and the posts page as designated in the WP Settings was given the blog template. I hope that makes sense..

    Based on the information you’re giving, I don’t think that the problem is with the code that is calling the header file. For the record, the correct call should be this:

    get_header( 'blog' );

    I think that the problem is actually that the template file that calls that code in the first place isn’t being read. The file should be named “page-blog.php”, not “blog-page.php”.

    Another option would be to include the following code in a comment at the very beginning of the file:

    /**
     * Template Name: Blog
     */

    Once this code has been included, you can specifically select this template to be used on your page. This setting is when you’re editing the content of your page.

    Thread Starter toastedonions

    (@toastedonions)

    Thanks for the suggestion! Unfortunately, it doesn’t appear to be changing anything, even when clearing my cache.

    The template was available in the dropdown when it was named blog-page.php, but I still tried page-blog.php and blog.php, which both show in the dropdown as well. I have the following at the top of this template page (an edited version of onecolumn-page.php that is in the Twenty Ten theme files):

    <?php
    /**
     * Template Name: Blog
     *
     * Blog page
     *
     * The "Template Name:" bit above allows this to be selectable
     * from a dropdown menu on the edit page screen.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    
    get_header( 'blog' ); ?>

    The only thing I changed just now was to put “‘blog'” back in. Knowing which is the correct call is a major relief in itself, though I’m not sure why it isn’t being seen. Is there a next step, maybe?

    Your main posts page will automatically use your theme’s index.php template file – irrespective of what page template you may have applied to it.

    Thread Starter toastedonions

    (@toastedonions)

    Thanks so much, esmi – that worked perfectly! I honestly didn’t realize that it would use index.php regardless, so I thank you for that invaluable bit of insight =)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘New header using get_header( $name); not working’ is closed to new replies.