Basic Hooks Question — Adding custom HTML

Community Forums Forums General Discussion Basic Hooks Question — Adding custom HTML

This topic is: not resolved

Tagged: 

This topic contains 7 replies, has 4 voices, and was last updated by  braddalton 1 year, 8 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #32172

    Gr8_Eight
    Participant
    Post count: 7

    Hi,

    1. Is there any disadvantage to using the simple hooks plugin?  E.g. If I use it wIth  child theme ,will I have a problem when the main genesis theme updates?

    2. Plugins aside, I’m trying to understand hooks by hand. My goal is to simply add the text (for example)

    <p>click here</p> to the ‘genesis_before_header’ area of the genesis sample theme.

    I’ve done a lot of reading and I simply can’t find the answer.

    In funcitons.php if I start with:

    add_action(‘genesis_before_header’ –where do I go from here?

    <p>click here</p>

    Thank you  in advance!

    #32188

    Peter
    Participant
    Post count: 1

    Hi

     

    you should have no probs using the plugin and updates to gegenesis particularly as you’re just putting in HTML as you say.

    to use this kind of

    add_action(‘genesis_before_header’ –where do I go from here?

    You need to write php code and create a function etc… If you’re not sure about this, the simple hook is the way to go!

     

    Peter


    === WordPress producer @ thedma.com.au ===

    #32213

    AC
    Blocked
    Post count: 7712

    On the “click here” I am assuming you are wanting to have it link to somewhere, correct? And do you want to add this so it shows up on every page of the site or on specific pages/posts?

    #32214

    AC
    Blocked
    Post count: 7712

    Also, have you read this – http://my.studiopress.com/docs/hooks/.

    #32218

    braddalton
    Participant
    Post count: 10598

    I think the Simple Hooks plugin is an excellent stepping stone to understanding hooks and thier locations.

    However i think at some stage you’ll move on to custom functions once you understand how hooks works and the different locations they execute.

    Using your child themes functions.php file is better than using Simple hooks because all your custom coding is contained in one file which is easier to manage.

    Here’s a very basic example of a custom function you can modify and use over and over again simply by changing the hook, div class for styling and unique name of the function.

    This enables you to easily display HTML or text in any genesis_hook location the same way Simple Hooks works but from your child themes functions.php file.

    https://gist.github.com/braddalton/5180457

    If you simply add text or HTML to a Simple Hooks field, you don’t get to target it with a class for styling unless you also add the class in the field as well.


    #32220

    AC
    Blocked
    Post count: 7712

    So then Brad, would you be able to answer this hook question I posted over here a few minutes ago?

    #32361

    Gr8_Eight
    Participant
    Post count: 7

    Thanks, Brad. This is EXACTLY what I was looking for!

     

     

    #32438

    braddalton
    Participant
    Post count: 10598

    I’ve also been writing alot about using hooks in custom functions with over 100 code snippets which you might find helpful.


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

You must be logged in to reply to this topic.