Site logo

Archived topic

Frontpage widgets

5 replies · Started by Alvaro on June 2, 2016

Viewing posts 1–6 of 6

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.

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?

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

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

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.

You're welcome. Glad you're enjoying GP :)

This archived topic is closed to new replies.