New div above content main w/o affecting core?
-
I’m just thinking aloud here. I noticed in Firebug that the divs for the content area are:
<div id="content" class="clearfix hfeed">
<div id="content-main" class="clearfix">
<div id="sidebar1" class="sidebar">There is nothing in the
content
div above thecontent-main
andsidebar1
divs. Would it be possible to insert a div abovecontent-main
/sidebar1
that would contain three images linked to three distinct pages without rewriting one of the theme’s core php files?I placed an edited version of the
header.php
in the child theme folder so I can show what I want to do. Here’s a screenshot of the idea I’m trying to get at (I’ll probably end up making the buttons a bit smaller, though the location is where I want them):Scroll right to view entire image
I don’t have the site up with this theme yet because I’m awaiting completing it before the public release of the site, hence only a screenshot.
Here’s the edited part of the file (what I’ve added is marked).
<?php do_action('graphene_before_content'); ?>
<div id="content" class="clearfix hfeed">
<!-- ADDED BY JOHN - ACTION CENTER IMAGES START -->
<div id="actioncenter" style="text-align:center;margin-bottom:10px;margin-top:-5px;">
<a href="#"><img src="http://www.greggcountygop.com/wp-content/uploads/2011/08/ActionCenter-ContributeRed.png" style="margin-right:15px;" alt="Contribute" /></a>
<a href="#"><img src="http://www.greggcountygop.com/wp-content/uploads/2011/08/ActionCenter-RegisterToVoteRed.png" alt="Register to vote" style="margin-right:15px;" /></a>
<a href="#"><img src="http://www.greggcountygop.com/wp-content/uploads/2011/08/ActionCenter-VolunteerRed.png" alt="Volunteer" /></a>
</div>
<!-- ADDED BY JOHN - ACTION CENTER IMAGES START -->
<?php do_action('graphene_before_content-main'); ?>
<?php
/* Sidebar1 on the left side? */
if ( in_array(graphene_column_mode(), array('two-col-right', 'three-col-right', 'three-col-center')) ){
get_sidebar();
}
/* Sidebar2 on the left side? */
if ( graphene_column_mode() == 'three-col-right' ){
get_sidebar('two');
}
?>
<div id="content-main" class="clearfix">I want to be able to do this without having to edit the
header.php
file and placing it in the child theme folder (which would make updating the site a bit less simple). Can this be done?AdminSure can. Perhaps it’s time you learn about using WordPress action hooks? Here’s a good primer on Action Hooks: http://www.nathanrice.net/blog/an-introduction-to-wordpress-action-hooks/
Here’s how. Insert this code into your child theme’s
functions.php
file:function graphene_custom_content(){
?>
// Insert your HTML codes here
<?php
}
add_action( 'graphene_before_content-main', 'graphene_custom_content' );Hi,
Thank you for an excellent theme.
I have been working with an increasingly growing child theme for Graphene at wmrt.jonlynch.co.uk . I regularly use the Action Hook list available here. I am very pleased to find that there is a before_content_main hook, are there any other hooks available that are not documented?
Jon
AdminActually, there are quite a few, since I continue to add more action hooks as needs arise. Updating the list for each update is rather…inconvenient. If you need a hook to be placed where there isn’t one currently, just ask 🙂
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.