[Resolved] Frontpage widgets

Home Forums Support [Resolved] Frontpage widgets

Home Forums Support Frontpage widgets

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #198847
    Alvaro

    Hi,

    I want to show frontpage specific 3 column widgets areas.

    I have created 3 new widget areas in my child-theme’s functions.php.

    I’ve managed to show the widgets using the generate_after_content hook.

    Question: How can I show this widgets only in the frontpage?

    I’m not certain how and where to put the if ( is_front_page() ) conditional tag.

    Thanks.

    • This topic was modified 5 years, 1 month ago by Alvaro.
    #198910
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Do the built in Footer Widgets not work for you?

    You would wrap that conditional around the content of your function. Are you using GP Hooks or a PHP function?

    #198919
    Alvaro

    Thanks Tom. This is what I’m using in my child’s functions.php to create the widget areas and hook them to GP: http://pastie.org/10861881

    So, I’m not sure were to put the conditionals…

    I just want this widget areas in my frontpage. It’s a way to get a custom frontpage using widgets.

    Thanks.

    Álvaro

    #198920
    Tom
    Lead Developer
    Lead Developer

    At the start of your function, do something like this:

    add_action( 'generate_before_footer', 'appacdm_frontpage_widgets' );
    function appacdm_frontpage_widgets() {
    
        if ( ! is_front_page() )
            return;
    
        // Get frontpage widgets to show
        ?>
    
        // The rest of your code...
    }
    #198992
    Alvaro

    Awesome! I was confused with my conditionals… yours worked perfectly.

    Thanks.

    Álvaro

    PS: great job with GeneratePress, BTW. I feel I’ll be using it often.

    #199023
    Tom
    Lead Developer
    Lead Developer

    You’re welcome. Glad you’re enjoying GP 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.