[Resolved] Conditional display of a full width call to action section AND footer widgets?

Home Forums Support [Resolved] Conditional display of a full width call to action section AND footer widgets?

Home Forums Support Conditional display of a full width call to action section AND footer widgets?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #153852

    I have GP Premium and would like to achieve the following footer layout:

    [ FOOTER ]

    With control over which pages display the CTA section and which pages display the footer widget section.

    How can I achieve this?


    To clarify this further – I would like to be able to show different calls to action (or no call to action) on different pages of the site. And I would like the same footer widgets to appear on most (but not all) pages site-wide.

    Lead Developer
    Lead Developer

    Hi there,

    For your call to action, I would suggest something like this: https://generatepress.com/forums/topic/change-site-header-and-title-based-on-page/#post-111841

    So you would:

    1. On your page, click the “Screen Options” tab at the top right of the page. Make sure the “Custom Fields” checkbox is checked.

    2. Now look for the “Custom Fields” metabox – click “Enter new”.

    3. Under “Name”, add: cta_section

    4. Under “Value”, enter the call to action.

    5. Now in GP Hooks, in the “Before Footer” hook, add this:

    global $post;
    $cta = get_post_meta($post->ID, 'cta_section', true);
    if ( ! empty( $cta) ) : ?>
          <div class="grid-container">
                <?php echo $cta; ?>
    <?php endif; ?>

    Be sure to check the “Execute PHP” checkbox.

    Then you can add your CTA in the custom fields section on each applicable page.

    For the footer widgets, you can just turn them on or off like this: https://generatepress.com/knowledgebase/choosing-footer-widgets/#individual

    Hope this helps 🙂


    Thanks Tom. The issue here is that I want both elements (CTA panel and 3 x footer widgets) to be displayed on most pages site-wide but not all. It would take far too long to individually edit all the pages to control the display of these elements.

    In other words, if I could just have this layout:

    [100% width footer widget]
    [33% widget][33% widget][33% widget]

    …combined with a plugin that allows easy control over which pages show each widget…

    That would be ideal. 🙂

    Do you see what I’m getting at? Any other ideas that might work here?


    Lead Developer
    Lead Developer

    For the footer widgets, just set your global setting to 3 widgets and then you can remove them on those select pages where you don’t want them using the metabox.

    For the CTA, it gets tricky.

    You could do something like this in GP Hooks:

    <?php if ( is_page( array( 1, 2, 3, 4 ) ) ) : ?>
        If the page ID is 1, 2, 3 or 4 (change these), show this text (or do nothing at all).
    <?php else : ?>
        Or else, show the CTA
    <?php endif; ?>

    Thanks Tom. I went with the first suggestion but reversed the test so that only those pages with the “hide_cta_section” custom field set to “true” don’t display the CTA. That seemed to be the easiest way to achieve this with the least amount of individual page editing.

    Lead Developer
    Lead Developer

    Awesome, thanks for sharing your solution! 🙂

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