ThemeShaper Forums » Thematic

[closed]

Action hook in header

(7 posts)
  • Started 8 years ago by astima
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. astima
    Member

    In my header I have a lot of space on the right and I want to enter text in that blank area. From what I have read I need to use action hooks. Through trial and error I have tried to write a function and action hook and place text in an area, but I have had no success. Many times I get an error message and other times the text appears below the header. Is it possible to get text to appear in that blank area?

    http://www.stimadesigns.com/ctc/

    Posted 8 years ago #
  2. dude, you really need to do more to help us help you. posting your link doesn't actually help, unless it demonstrates a problem. what code are you using? i'd probably hook on to the thematic_header hook at priority 6. define widths for blog-title and blog-description and then float your new div to the right

    http://www.bluemandala.com/thematic/thematic-structure.html

    Posted 8 years ago #
  3. astima
    Member

    I'm sorry for my lack of information. I am in way over my head. This isn't even going to be an active site. I'm just practicing. I have never even heard of action hooks until I started using this theme. So from what I have read about action hooks, this is the hook I wrote in order to get text to appear in the empty space to the right in my header.

    <?php
    function header_left() { ?>
    <div>
    <p>New York Talent. New Jersey Budgets. A Whole New Approach.</p>
    </div>
    <?php
    }
    //add_action('thematic_header', 'header_left');
    ?>

    So my hurdle is where to place the action hook. I am assuming it goes in the thematic header.php. I have moved it around quite a bit to try to find where it goes, but have been unsuccessful.
    As I am writing this post, I realize my site is not working, it says the server is not connecting. So I can not get the rest of my code to show you where I placed it in header.php. But if you could at least tell me if I wrote the hook correctly and then once I figure out why my site is not working I will find where I inserted the code.

    Posted 8 years ago #
  4. astima
    Member

    My site is working again. So here is where I placed the action hook. This is the section of the header.php:
    // action hook for placing content above the theme header
    thematic_aboveheader();

    ?>
    <div id="header">

    <?php
    // action hook creating the theme header
    thematic_header();
    <?php
    function header_left() { ?>
    <div>
    <p>New York Talent. New Jersey Budgets. A Whole New Approach.</p>
    </div>
    <?php
    }
    //add_action('thematic_header', 'header_left');
    ?>

    ?>

    </div><!-- #header-->

    Posted 8 years ago #
  5. i understand it can be difficult to ask good questions when you don't know terminology, but generally the more info you can provide the easier it is for us to help. oh and we (or at least i personally) like to see that you've put in some effort to learning it. :) but for being in over your head:

    <?php
    function header_left() { ?>
    <div>
    <p>New York Talent. New Jersey Budgets. A Whole New Approach.</p>
    </div>
    <?php
    }
    add_action('thematic_header', 'header_left');
    ?>

    is almost perfect. if you weren't dealing w/ the thematic_header hook it would be perfect, but b/c thematic_header has multiple functions attached to it, you need to use what is called priority... a number that determines the order the functions at a particular hook are run in. sort of like a traffic cop at an intersection.

    if you revisit the link i posted above, you'll see that the branding div closes at priority 7. depending on what you want (i think either could work here) i think it'd be best to put your function at priority 6 (just inside #branding) or on 8 (just after #branding)

    so like this:

    add_action('thematic_header', 'header_left',8);

    now your new div is in the markup and you can finesse the CSS. i strongly urge you to http://getfirebug.com to help w/ all CSS questions (or use chrome's built-in developer tools). and once it is in the markup, we'll be able to visit your site and offer more help.

    btw- put code between backticks. if you have an american keyboard it is usually in the upper left corner next to the 1, sharing a key with the ~

    Posted 8 years ago #
  6. astima
    Member

    Thank you for your help with action hooks. When I insert the hook into the code I would get an error message. You know the one where it tells you there is an error on a specific line. No matter where in the code, the error message always refers to the function code line. I figured eventually through trial and error I would find the right spot, however after a while I started getting this warning:

    Warning: Cannot modify header information - headers already sent by (output started at /home2/stimades/public_html/ctc/wp-content/themes/gallery/functions.php:1247) in /home2/stimades/public_html/ctc/wp-admin/theme-editor.php on line 99
    It was really messing up my site so I uninstalled and reinstalled the thematic theme and that fixed the problem. I am hesitant to continue with the trial and error approach since I have never seen this error message before and I don't know what it means. In which file should be placing the action hook? I thought it should come in the header.php in the thematic theme not in the functions.php in the gallery theme.
    I thought that the action hook should go below the following line in the header.php file:

    // action hook creating the theme header
            thematic_header();
    Posted 8 years ago #
  7. the headers already sent error usually means that you have a file that closes the php brackets and then has extra space after that.

    <?php
    //lots o' bacon-flavored code
    ?>
    
    error causing space

    the code goes in your child theme's (in this case gallery) functions.php

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.