getButterfly Logo getButterfly code wrangling since 2005

Social Payments is a social gateway plugin for WordPress. It allows the user to place a shortcode inside a post or a page and hide the content. So far, so good.

What happens when you need to add it programmatically inside the PHP template? Maybe you want to use it in bulk and not spend time manually adding it to all posts and pages.

Use your page.php (or single.php) template and replace the_content() with the following code:

$content = get_the_content();
$content = '[ social-sell ]' . $content . '[ /social-sell ]';

echo do_shortcode($content);

The code also works with custom posts, you only need to find the single-customposttypehere.php template and replace the content.

Note #1: Remove the space before and after the square brackets. I have added it in order not to interact with the actual plugin, which is active on my site.

Note #2: you can use any other shortcode instead of the one above, for any other plugin you might have. It will work.

Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

Leave a reply