First published on Internoetics years ago, and then migrated to the Belief website in 2014 as a draft, this article has lived with dozens of others in a state of uncertain purgatory. We expected to include a library of functions and shortcodes that would render various social icons and widgets into your WordPress post or page (which we have effectively done) before showing how they all might be rendered at the top or bottom of each page on your website. With the introduction of Gutenberg, our shift towards Elementor for clients, our own sharebar code, and the inclusion of a fully integrated mortgage broker website, the feature we intended to package up as a plugin a number of years ago is now a little less relevant now than it once was.
A short time ago we introduced how Yabber will render content above or below your content on the basis of an inbound email campaign link, and we also introduced how you might show time-limited content above or below your website articles to defined audiences. If you're familiar with our core marketing philosophy you'll also appreciate how we espouse that a a subscription form be shown on every single page of your website. This article introduces the code necessary to implement the features yourself.
One of the many filters made available within WordPress is the_content filter. What it essentially does it take your post content, does something with it, then spits it out at the other end with the appropriate modifications applied. You might do something nutty such as apply Pirate Day text, or use the filter to evaluate text for more usable replacements, such as geographic placeholders. In our case, we'll ignore the text completely and simply bolt on some additional HTML to either side of our post content.
The WordPress Function
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.
If you were to use the above function you would simply assign some text to the
$b variable (inside the quotes) making sure to escape single quotes with a \slash. Depending on how your system is structured you may have to wrap your content into paragraph tags. Any shortcodes in yoru content should run, but if a later priority was set you can still wrap the do_shortcode() function around your custom content variables.
Your content can come from anywhere, such as an external API, anywhere in your database, or external code (such as embed code).
At some point we'll create a WordPress plugin to enable ease in assigning the content, and we'll introduce some conditional features so the content only returns on certain pages. In the meantime the custom functions options is normally more than suitable.