- This topic has 6 replies, 2 voices, and was last updated 5 years ago by Tom.
November 18, 2015 at 12:02 am #153852Anton
I have GP Premium and would like to achieve the following footer layout:
[ FULL-WIDTH CALL TO ACTION SECTION ]
[FOOTER WIDGET 1][FOOTER WIDGET 2][FOOTER WIDGET 3]
[ FOOTER ]
With control over which pages display the CTA section and which pages display the footer widget section.
How can I achieve this?November 18, 2015 at 12:34 am #153868Anton
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.November 18, 2015 at 12:45 am #153872TomLead DeveloperLead Developer
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:
<?php global $post; $cta = get_post_meta($post->ID, 'cta_section', true); if ( ! empty( $cta) ) : ?> <div class="grid-container"> <?php echo $cta; ?> </div> <?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 🙂November 18, 2015 at 6:57 pm #154099Anton
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?
AntonNovember 18, 2015 at 10:08 pm #154135TomLead DeveloperLead 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; ?>November 23, 2015 at 12:27 am #154891Anton
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.November 23, 2015 at 8:51 am #154987
- You must be logged in to reply to this topic.