ThemeShaper Forums » Thematic

Modify Header Output With Functions.php

(9 posts)
  • Started 10 years ago by mr.macian
  • Latest reply from shelzmike
  • This topic is resolved
  1. mr.macian
    Member

    I would like to modify the html the header outputs. I want something like this:

    <div id="header">
         <div id="bloginfo">
              <h1 id="blog-title"></div>
              <div id="blog-description"></div>
         </div><!--#bloginfo-->
         <div id="search"></div>
         <div id="navigation"></div>
    </div><!--#header-->

    The basic modification is that I want a search area next to the blog title, and I want the navigation underneath both. I presume this can be done using a custom functions.php file, and I am wondering if anyone could give me some pointers on how to accomplish that.

    Posted 10 years ago #
  2. mr.macian
    Member

    I think I have figured this out, and decided to post my solution in case anyone in the future would like to do something similar.

    This is all done via a custom functions.php file in a child theme directory. No need to touch any of the default thematic files.

    Let's assume one wants the following output in the header:

    <div id="header">
         <div id="bloginfo">
              <h1 id="blog-title"></div>
              <div id="blog-description"></div>
         </div><!--#bloginfo-->
         <div id="search"></div>
         <div id="navigation"></div>
    </div><!--#header-->

    First, you need to remove some of the default output by putting the following into your functions.php file:

    // Take Away Default Thematic Header
    function new_header() {
    	remove_action('thematic_header','thematic_brandingopen',1);
    	remove_action('thematic_header','thematic_blogtitle',3);
            remove_action('thematic_header','thematic_blogdescription',5);
    	remove_action('thematic_header','thematic_brandingclose',7);
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'new_header');

    Now that you have removed some of the default output, you can add your own custom output by doing the following:

    // Insert Custom Header
    function custom_header() { ?>
        <div id="bloginfo">
             <h1 id="blog-title"></h1>
             <div id="blog-description"></div>
        </div><!-- #bloginfo -->
        <div id="navigation"></div>
    <?php }
    add_action('thematic_header','custom_header');

    That should do the trick.

    Posted 10 years ago #
  3. Exactly the info I needed, found via search. Thanks!

    Posted 10 years ago #
  4. shelzmike
    Member

    Nice - this is pretty much what I need to do, but in the name of education here - I really want to learn what it is I am doing. Well, actually..I sort of already know, but the one thing I cannot figure out is where do I find what actions are included in each hook? In other words, how do I know (If I am trying to do this on my ow later, which I do) what actions I need to remove? That is the part that I cannot find information on. Thanks in advance for help!

    Mike

    Posted 9 years ago #
  5. Have you read through the information available on Ian Stewart's site? http://themeshaper.com/ . All of this coding(php),wordpress and functions are new to me and I'm slowly working things out. This diagram will come in handy understanding the Thematic Page Structure http://bluemandala.com/thematic/thematic-structure.html

    Posted 9 years ago #
  6. shelzmike
    Member

    Cool - I appreciate all the help. I finally made a little breakthrough in understanding. I just could not find the functions where the actions were (so I would know what I needed/wanted to remove). I figured out that they are in the extensions directory - like the ones for thematic_header() are in the header-extensions.php file.

    So, what I have figured out (and maybe it is pointed out in the themeshaper site - I just didn't pick it up that well!) is that the "actions" are actually the functions that are within the main functions (thematic_header in this instance) and what I am removing are those functions (which are also referred to as actions?). So, would that mean that the "position number" that I am reading about is what place within the main function the action I am replacing is located? If so I am confused as to what that matters, but I do not need to know that so long as it works.

    I am also fairly new to php and am confused at the positioning of the opening and closing <?php and ?> tags. Seems like they are out of place from what I know about php, but I guess I will eventually work it out.

    Thanks again for your help!

    Mike

    Posted 9 years ago #
  7. shelzmike
    Member

    Okay, I tried this and now get an unexpected "}" parse error. Looks like it has to do with the php tags I was referring to.

    Mike

    Posted 9 years ago #
  8. amygail
    Member

    shelzmike - you've probably just got a simple syntax error (and unexpected } somewhere...

    Can you post the function?

    (The opening and closing php tags go at the very beginning and end of your functions.php file)

    Posted 9 years ago #
  9. shelzmike
    Member

    I figured this out...it was a stupid and obvious error (well, maybe not so much for the newbie like me who take code examples like the above literally - meaning adding nothing taking nothing away except the custom content. I did not have the opening <?php tag at the very beginning of the functions.php file! Doh. :D

    Thanks.

    Posted 9 years ago #

RSS feed for this topic

Reply

You must log in to post.