Append a specified (private) page to all pages and posts
Last September I wrote about injecting the content of a private page into posts and pages. A few days ago a member of the Genesis WordPress Facebook group asked how to append a Mailchimp form to the bottom of all posts and pages. I’ve reworked the code a bit to achieve this.
Filter and action
As the question was posted in the Genesis group I can assume that a Genesis theme is in use. This gives two possible solutions – using ‘the_content‘ filter (which should work for all themes) or a Genesis specific action e.g. ‘genesis_after_entry_content‘. For completeness I wrote code for both.
I left out the sidebar option because the poster said that the Mailchimp form was a block (and not a widget).
I created a private page and added a Contact Form 7 shortcode and a Cover block (an image with text on top) and used this. I figured that this would be a good test to ensure that the shortcode was expanded and the block was correctly rendered. Both worked!
I used a private page so that it is kept hidden from site visitors.