Unexpected behavior with hooks

Community Forums Forums Design Tips and Tricks Unexpected behavior with hooks

This topic is: resolved

This topic contains 3 replies, has 2 voices, and was last updated by  macaines 1 year, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46557

    macaines
    Participant
    Post count: 8

    Hi all…

    First post…new with Genesis but liking it so far.

    Looking for some insight as to why I’m getting the following behavior with some hooks implementation…perhaps I’m going about this the wrong way and would appreciate some assistance.

    Essentially, I’d like to modify the Genesis Sample theme as follows…

    Before…

     
    <div id="wrap">
        <div id="header">...</div>
        <div id="nav">...</div>
        <div id="inner">...</div>
        etc...

    After…

    <div id="header">...</div>
    <div id="wrap">
        <div id="nav">...</div>
        <div id="inner">...</div>
        etc...

    This modification based on my Googling is pretty straightforward by adding the following code to functions.php

    /** Reposition header outside main wrap */
    remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
    remove_action( 'genesis_header', 'genesis_do_header' );
    remove_action( 'genesis_header', 'genesis_header_markup_close', 15 ) ;
    
    add_action( 'genesis_before', 'genesis_header_markup_open', 5 );
    add_action( 'genesis_before', 'genesis_do_header' );
    add_action( 'genesis_before', 'genesis_header_markup_close', 15 );

    Here’s where it gets a bit wonky…if I were to try to add another new div called pre-header above the header area, so that it looks like this…

    <div id="pre-header">...</div>
    <div id="header">...</div>
    <div id="wrap">
            <div id="nav">...</div>
            <div id="inner">...</div>
            etc...

    …I would assume that I could define a custom function like this in functions.php…

    function do_preheader()
    {
    printf( ‘<div id=”pre-header”></div>’);
    }

    …and add the following hook to functions.php…

    add_action( ‘genesis_before’, ‘do_preheader’ );

    but instead what I end up getting is this…

    <div id="header">
        <div id="wrap">
            <div id="pre-header"></div>
            <div id="title-area">...</div>
            <div id="widget-area">...</div>
        </div>
    </div>
    <div id="wrap>...</div>

    Perhaps I’m way off here…perhaps there’s a technique I’m missing or not yet aware of….thanks for any insight or help with this!!

    Michael

    • This topic was modified 1 year, 4 months ago by  macaines.
    • This topic was modified 1 year, 4 months ago by  macaines.
    • This topic was modified 1 year, 4 months ago by  macaines.
    • This topic was modified 1 year, 4 months ago by  macaines.
    #46565

    braddalton
    Participant
    Post count: 10342

    Hi Michael

    What exactly do you need to do?

    Are you running HTML 5?


    #46571

    macaines
    Participant
    Post count: 8

    Hi Brad,

    I was a bit long-winded with my post…:)

    Essentially I would like to move the header area outside of the wrap div and add another div on top called pre-header like so…

    <div id="pre-header">...</div>
    <div id="header">...</div>
    <div id="wrap">
            <div id="nav">...</div>
            <div id="inner">...</div>
            etc...

    I’m running Genesis 1.9.2 so I don’t believe that it’s fully Html5

    Thanks,
    Michael

    • This reply was modified 1 year, 4 months ago by  macaines.
    • This reply was modified 1 year, 4 months ago by  macaines.
    #46743

    macaines
    Participant
    Post count: 8

    I found the problem…

    It was a priority issue with the hooks being called.

    I changed

    add_action( ‘genesis_before’, ‘do_preheader’ );

    to

    add_action( ‘genesis_before’, ‘do_preheader’,1 );

    and the expected results occurred.

    Michael

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Unexpected behavior with hooks’ is closed to new replies.