Community Forums › Forums › Archived Forums › General Discussion › add_action('genesis_before_content_sidebar_wrap ', 'function'); outputting code.
Tagged: function, hooks, html, must use plugin, wrap
- This topic has 9 replies, 2 voices, and was last updated 8 years, 4 months ago by Christoph.
-
AuthorPosts
-
August 12, 2016 at 1:13 pm #191177aschoenbrunMember
Hi,
I am using a modified version of the Sample Genesis starter child theme by Sridhar Katakam (https://github.com/srikat/genesis-sample). I am trying to add multiple custom divs to wrap around the site content. This is so I can use the technique found here (http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks).
I've placed the following code in a "Must Use" plugin:
function framework_content_adjust() { // 1 - Equal Height Element wrapper tops add_action('genesis_before_content_sidebar_wrap ', 'equal_height_content_start'); function equal_height_content_start() { ?> <div id="ContentWrapper"> <div id="SidebarBorder"> <div id="ContentReplace"> <?php } // 2 - Equal Height Element wrapper bottoms add_action('genesis_after_content_sidebar_wrap', 'equal_height_content_end'); function equal_height_content_end() { ?> </div> </div> </div> <?php } } add_action('after_setup_theme', 'framework_content_adjust', 2, 50);
I know the code is executing to some degree, since while testing I moved all code to the first plugin and a conflict was noted.
What am I doing wrong that is stopping this code from outputting the HTML markup?
Thank you so much.
http://torahthinking-genesis.youreffectivemedia.com/August 12, 2016 at 1:42 pm #191182ChristophMemberHi,
not sure why you'd want to use that method (or if that is the right hook), but just echo your markup.
echo '<div id="ContentWrapper"><div id="SidebarBorder"><div id="ContentReplace">';
No need to switch in and out of php.
http://prntscr.com/c4z2u2
August 12, 2016 at 1:49 pm #191183aschoenbrunMemberThanks for answering, Christoph,
I switch in and out since it's easier for me to code HTML without getting distracted by php. I made the changes anyway to see if that would work:
function framework_content_adjust() { // 1 - Equal Height Element wrapper tops add_action('genesis_before_content_sidebar_wrap ', 'equal_height_content_start'); function equal_height_content_start() { echo '<div id="ContentWrapper"><div id="SidebarBorder"><div id="ContentReplace">'; } // 2 - Equal Height Element wrapper bottoms add_action('genesis_after_content_sidebar_wrap', 'equal_height_content_end'); function equal_height_content_end() { echo '</div></div></div>'; } } add_action('after_setup_theme', 'framework_content_adjust', 2, 50);
Still, the changes are not being reflected.
August 12, 2016 at 2:11 pm #191184ChristophMemberTry using
'genesis_after_header'
instead of
'after_setup_theme'
August 12, 2016 at 2:32 pm #191186aschoenbrunMemberNothing.
I must say I've been having a lot of trouble hooking and unhooking functions, some of which are essentially simple html. The only success I've had was the first MU plugin I did to replace the site title with the logo.
function framework_header_adjust() { // 1, 2, 3 - Replace name and description with logo remove_action( 'genesis_site_title', 'genesis_seo_site_title' ); remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); add_action('genesis_site_title', 'ttg_logo'); function ttg_logo() { ?> <div id="Logo"> <?php $attachment_id = get_field('Logo', 'options'); $size = "Logo"; $image = wp_get_attachment_image_src( $attachment_id, $size ); // url = $image[0]; // width = $image[1]; // height = $image[2]; ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <img src="<?php echo $image[0]; ?>" alt="<?php bloginfo('name'); ?>" /> </a> </div> <?php } } add_action('after_setup_theme','framework_header_adjust', 1, 50);
Any subsequent hooking or unhooking has not worked, whether added as an MU plugin or applied straight to the child theme's functions.php. Please note I have been referencing the hooks and actions by searching through the Genesis parent theme folder ans well as by using the Genesis Visual Hook Guide plugin (https://wordpress.org/plugins/genesis-visual-hook-guide/)
August 12, 2016 at 2:35 pm #191189aschoenbrunMemberI want to add custom content to this site. I must be going about it wrong, I just dont know how
August 12, 2016 at 2:41 pm #191190aschoenbrunMemberDid a test in that MU plugin for the divs:
add_action('genesis_before_content_sidebar_wrap', 'ttg_test'); function ttg_test() { echo '<p>Hello</p>'; }
It worked. So now I'm even more confused
August 12, 2016 at 2:44 pm #191191aschoenbrunMember// 1 - Equal Height Element wrapper tops add_action('genesis_before_content_sidebar_wrap ', 'equal_height_content_start'); function equal_height_content_start() { echo '<p>Hello</p>'; } // 2 - Equal Height Element wrapper bottoms add_action('genesis_after_content_sidebar_wrap', 'equal_height_content_end'); function equal_height_content_end() { echo '<p>Hello</p>'; }
Did not work. Must be something wrong with those specifically
August 12, 2016 at 2:57 pm #191192aschoenbrunMemberWorks now. I have no idea what did it. I copied and pasted one action to the other, then modified to match original. I added `echo '<p>Hello</p>' to each, then removed. After all said & done, it works. The only thing I can think of is that when I copied the hook text, somehow hidden characters came along. I have no idea why they would though. I use Atom, which, at its core, is a text editor (I believe.). Any insight woudl be appreciated...
Thanks so much Christoph`August 12, 2016 at 3:13 pm #191194ChristophMemberWonderful!
I´m happy it started to work. 🙂I can't really tell you what was going on.
Maybe a line-break, maybe something else.
Your code (when not on the after_setup_theme hook) worked for me in functions.php and a mu plugin.I was/am using Atom (with about 20+ packages /extensions), too.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.