eleven40 child theme. Hide the "Title" Widget.

Community Forums Forums Design Tips and Tricks eleven40 child theme. Hide the "Title" Widget.

This topic is: resolved

This topic contains 8 replies, has 3 voices, and was last updated by  braddalton 1 year, 6 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #25034

    jasonfox
    Participant
    Post count: 6

    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.

    http://www.jasonfox.me

    Can anyone share the code snippet with me and I think is the before_content hook?

    Jason

    #25064

    braddalton
    Participant
    Post count: 10245

    You 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 widget

    The first 2 solutions are the best and the plugin is the easiest option.

    Examples:
    [php]
    !is_page
    [/php]

    or
    [php]
    !is_page_template
    [/php]


    #25078

    jasonfox
    Participant
    Post count: 6

    Thanks Brad,  the plugin did the trick.

    #32179

    Chris Moore
    Participant
    Post count: 136

    @braddalton:

    You 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.com

    #32181

    Chris Moore
    Participant
    Post count: 136

    I 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.com

    #32194

    braddalton
    Participant
    Post count: 10245

    is_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.


    #32197

    Chris Moore
    Participant
    Post count: 136

    I’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.com

    #32200

    Chris Moore
    Participant
    Post count: 136

    Okay, 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.com

    #32208

    braddalton
    Participant
    Post count: 10245

    No 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.


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

You must be logged in to reply to this topic.