I am working on a site for a fundraising campaign for a toddler with cancer. I started with the Essence Pro theme from StudioPress. During the site development I was asked to remove the page title from on top of the hero image.
Find the code
Using “Inspect Element” I saw that the title was in a block with the class (and id) “hero-page-title“. I found this in essence-pro/lib/title-functions.php in the essence_header_title_wrap() function. This function was set up in the essence_page_hero_header() function to be called in the ‘genesis_meta‘ action.
My first test was to add my own function to the ‘genesis_meta’ action to run before essence_page_hero_header() was run. I would simply remove_action() ‘essence_page_hero_header‘. Unfortunately this resulted in the removal of the hero image too.
Reading essence_page_hero_header() again I saw that it creates the markup for the ‘hero-page-title‘ area and moves the title and surrounding markup into this area. This is done by calling remove_action() to disable the default inclusion at the top of the post/page content area and calling add_action() to include it in the hero area (using the ‘essence_entry_header‘ action declared in essence_header_title_wrap()). This is what I really like about Genesis – it’s a bunch of functions that are called during page creation and changing the order in which they are called is really easy. It’s also very easy to inject new functions into the flow.
My second version of the code retained the remove_action() of ‘essence_page_hero_header‘ but added the four add_action() calls to create the header area. The default inclusion of the title and markup at the top of the post/page content was not changed.
Later I needed to disable the hero image on one page. I did this by returning early from the function thus skipping the hero section’s add_action() calls for that page.