Skip to content

Instantly share code, notes, and snippets.

@JRMorris77
Created November 18, 2017 08:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JRMorris77/37aa36d60d5bc2b544a7e561804e9da5 to your computer and use it in GitHub Desktop.
Save JRMorris77/37aa36d60d5bc2b544a7e561804e9da5 to your computer and use it in GitHub Desktop.
Add HTML or Shortcode before or after the_content() - WordPress mu-plugin
<?php
// This particular example adds Hustle Social Sharing shortcode after content without editing template files on single posts/pages only.
function jmorris_before_after($content) {
$beforecontent = '';
if ( is_single() ) {
$aftercontent = '[wd_hustle_ss id="jmorris-online"]';
} else {
$aftercontent = '';
}
$fullcontent = $beforecontent . $content . $aftercontent;
return $fullcontent;
}
add_filter('the_content', 'jmorris_before_after');
@oldbooklover
Copy link

oldbooklover commented Jun 30, 2022

I want to put the short code before and after the h2 tag in the single post
Any help is appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment