Add widget to home page – Metric theme

Community Forums Forums Design Tips and Tricks Add widget to home page – Metric theme

This topic is: resolved

This topic contains 14 replies, has 3 voices, and was last updated by  anitac 1 year, 1 month ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #24121

    stefan
    Participant
    Post count: 9

    Hi guys,

    I’m trying to add a full width widget on the home page of the Metric theme, directly above the 3 widgets called ‘Home Middle #1-3′, so between the blue and white parts of the site – http://cabinetdesigner.net/.

    I think I now know how to register a widget and hook it to the home page – as described here http://www.briangardner.com/home-widget-area-eleven40/ – but I’m not sure what hook to use (genesis_before_loop or another?), or where in home.php to put it.

    Any help greatly appreciated.

    Thanks very much,

    Stefan

    #24128

    anitac
    Participant
    Post count: 6489

    You can use the Visual Hook Guide to select the location that you want – http://genesistutorials.com/visual-hook-guide/.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #24131

    braddalton
    Participant
    Post count: 7472

    Paste this code at the end of your child themes functions.php file rather than edit the home.php file;

    Remove any code you have already added to register the widget.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #24132

    stefan
    Participant
    Post count: 9

    Hi, Anitac.

    Thanks for your response. I’m still stuck though.

    I cannot work out how the guide applies to a home page, particularly a position in between the various widget areas already there.

    Thanks again,

    Stefan

    #24135

    stefan
    Participant
    Post count: 9

    Hi Brad. Thanks as well. I added the code at the bottom of the functions file, and cannot see anything any change on the home page, but it does appear at the top of posts e.g. http://cabinetdesigner.net/design-a-cabinet-under-a-roof/, which seems strange.

    #24136

    braddalton
    Participant
    Post count: 7472

    Here’s the code

    genesis_register_sidebar( array(
    'id' => 'home-custom',
    'name' => __( 'Home Slider', 'metric' ),
    'description' => __( 'This is the custom widget area for your homepage.', 'metric' ),
    ) );
     
    add_action( 'genesis_before_content_sidebar_wrap', 'child_before_content');
    function child_before_content() {
    if ( is_home() ) {
    echo '<div id="home-custom">';
    dynamic_sidebar( 'home-custom' );
    echo '</div><!-- end #home-custom -->';
    }
     }
    

    Modify the sample CSS below or add more declarations:

    .home-custom {
    background: #f2f2f2;
    padding: 5px;
    border: 5px solid #D4D0C8;
    }
    

    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #24138

    stefan
    Participant
    Post count: 9

    Thanks, Brad. I’ve added that, and put a text widget in that new widget area with ‘text to follow’ as the content…but I still cannot see it for some reason.

    #24146

    braddalton
    Participant
    Post count: 7472

    Yes you’re right Stefan.

    It doesn’t work on that theme because the home.php file is coded differently to the newer themes so you might need to custom code the home.php file as the genesis_hooks won’t output the widget area exactly where you want using a custom function.

    I’ve tried using different hooks but it still doesn’t work.

    My code uses a conditional tag is_home so it only displays on the home page.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #24148

    stefan
    Participant
    Post count: 9

    OK, thanks again. I’ll see if I can see how the other widgets have been generated, and replicate one of those. Wish me luck!

    #24158

    anitac
    Participant
    Post count: 6489

    I was able to get this coded for you. I had Metric installed. I will post it down below.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #24164

    anitac
    Participant
    Post count: 6489
    This reply has been marked as private.
    #24171

    stefan
    Participant
    Post count: 9

    Just emailed your info@ address – thanks v much

    #24174

    anitac
    Participant
    Post count: 6489

    I sent them! Let me know how it turns out.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

    #24190

    stefan
    Participant
    Post count: 9

    Worked PERFECTLY! It’s on a test site at the moment, but will be on the one I mentioned above soon.

    Thank you very much!!!!

    (I can go to bed happy now, getting late here in the UK)

    #24515

    anitac
    Participant
    Post count: 6489

    @Stefan, it looks great! Glad I could help.


    Let me help you customize your theme, responsive header, Buddypress, Agentpress or technical issue!
    Visit me here: Cre8tiveDiva.com | Tweet Me! | Plus Me!
    When asking for help, please provide a link or screen shot showing your problem!

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

The topic ‘Add widget to home page – Metric theme’ is closed to new replies.