How to add a new div to a web-page?

Community Forums Forums Design Tips and Tricks How to add a new div to a web-page?

This topic is: not resolved

This topic contains 2 replies, has 2 voices, and was last updated by  CharlieL 1 year, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4442

    CharlieL
    Participant
    Post count: 24

    As I am not a PHP-guy I wonder if it is a big task to only add a div, to all pages in a theme?

    Say, I want to add a banner-div to the #header in the Eleven40 theme. How do I code it in the functions.php?
    I prefer not to add a widget as this is nothing that is going to be edited by the user. It will be set in the CSS.

    I know that the CSS has to be adjusted to the new setup, but it is the PHP that is the hard thing.

    #4648

    ramseyp
    Participant
    Post count: 99

    Charlie,

    You’re talking about using the Hooks that Genesis has in it for adding & removing structure and content to a theme. If you want to add a div above the header, for example, you would use the genesis_before_header hook to add the action that outputs the new div.

    There is a good article on the Genesis framework here, along with the next one, which goes through the add_action steps. I’ve created a Gist with some example code that you can use in your functions.php file: https://gist.github.com/4265532

    The trick is the div’s contents. If it’s hardcoded, you can code the content into the HTML in the function. Otherwise, you need to include some means of inserting content: a widget, a Loop that grabs a Post or Page, something that reads a settings field in theme settings, etc. It can get more advanced if you’re not experienced at this, but it’s not at all impossible.


    #4673

    CharlieL
    Participant
    Post count: 24

    Ramseyp,

    Great comment, thank you so much!
    Those two articles by Nick I have never seen before, even if I have read a lot of good stuff from him.  I will study them and try to learn more about the Genesis framework.

    I also really appreciate your code. Now I have something to try and make some experiments with. I think this will take me forward as it was in line with what I expected. Nice to know that HTML can be used within a function as I am much more acquainted with HTML and CSS than PHP.

    Thank you Ramseyp for helping me.

     

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

You must be logged in to reply to this topic.