Community Forums › Forums › Archived Forums › Design Tips and Tricks › eleven40 child theme. Hide the "Title" Widget.
- This topic has 8 replies, 3 voices, and was last updated 11 years, 10 months ago by Brad Dalton.
-
AuthorPosts
-
March 8, 2013 at 1:18 pm #25034jasonfoxMember
Hello,
I am using the "Title" widget as an opt in on the home page. And would like to hide it on all other pages. I have simple hooks installed and tried multiple variations of remove_action but cant quite get it.
Jason Fox Real Estate Marketing | Real Estate Website Design
Can anyone share the code snippet with me and I think is the before_content hook?
Jason
March 8, 2013 at 4:59 pm #25064Brad DaltonParticipantYou can do this several ways:
1. Install the Widget Logic plugin and add a conditional tag
2. Add a conditional tag to the function which displays the widget in the hook location
3. Use CSS code to hide the display of the widgetThe first 2 solutions are the best and the plugin is the easiest option.
Examples:
!is_page
or
!is_page_template
March 8, 2013 at 5:37 pm #25078jasonfoxMemberThanks Brad, the plugin did the trick.
March 30, 2013 at 9:33 pm #32179Chris MooreMemberYou said:
2. Add a conditional tag to the function which displays the widget in the hook location
Could you please specify the exact code for functions.php I would use to display the Page Title widget (in the eleven40 child theme) only on the front page of a site (the homepage)?
Thanks for your help!
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comMarch 30, 2013 at 9:46 pm #32181Chris MooreMemberI found this code snippet in the eleven40 functions.php. I know this is the snippet I need to work with, but I just need to know exactly what I need to add to this code to make the page title widget only appear on the front page of the site (which is where the blog posts display).
/** Add the page title section */
add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_page_title' );
function eleven40_page_title() {
genesis_widget_area( 'page-title', array(
'before' => '',
) );
}
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comMarch 30, 2013 at 11:20 pm #32194Brad DaltonParticipantis_home or is_front_page
Here's all the code where you'll find what you need https://gist.github.com/braddalton
Work out the hook location and change the hook if needed.
March 30, 2013 at 11:24 pm #32197Chris MooreMemberI'm sorry for the trouble @braddalton, but would you be so kind as to actually spell out for me where the is_home or is_front_page should go in this snippet:
/** Add the page title section */
add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_page_title' );
function eleven40_page_title() {
genesis_widget_area( 'page-title', array(
'before' => '',
) );
}
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comMarch 30, 2013 at 11:52 pm #32200Chris MooreMemberOkay, after fooling around with all kinds of different variations in the code, I got this one to work. Just wanted to check back and see if this is the "best" way to do it, and if the code is "clean"... Thanks!
/** Add the page title section */
add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_page_title' );
function eleven40_page_title() {
if ( is_home() && is_active_sidebar( 'page-title' ) )
genesis_widget_area( 'page-title', array(
'before' => '',
) );
}
Resepctfully, Chris Moore
Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.comMarch 31, 2013 at 3:19 am #32208Brad DaltonParticipantNo trouble and always happy to help Chris.
I would have simply used the existing code for this hook location with the conditional tag for homepage.
I guess you learn't a bit about custom functions, conditionals and genesis hooks which is good.
I cannot see the code for registering the widget however it works so must be o.k.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.