Created
November 18, 2017 08:41
-
-
Save JRMorris77/37aa36d60d5bc2b544a7e561804e9da5 to your computer and use it in GitHub Desktop.
Add HTML or Shortcode before or after the_content() - WordPress mu-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to put the short code before and after the h2 tag in the single post
Any help is appreciated