How to Automatically Add Content After Post in WordPress?
Many a time there is a need to automatically show standard content after each post in WordPress.
If you are having a similar need then you are in the right place. In this post, you will learn how to automatically add content after post in WordPress.
Displaying a block of text after the post can be quite useful as it is a great spot that can be you used to mention any update that the readers should know. Also, you might want to add an affiliate disclosure to each post.
Unfortunately, WordPress does not have a straightforward way to automatically add display content after the post.
However, there are many ways to do this, with the use of plugins and without the use of plugins.
Add Content After Post in WordPress using plugin
This is the simplest method if you don’t want to go through the hassle of editing the code in functions.php file.
The WordPress plugin that you can use for automatically adding content after post is the Add Widget After Content.
This plugin is available for free of cost in the WordPress plugin directory.
This plugin basically adds a content area after the post content but before the comments section.
How To Use Add Widget After Content Plugin to add content after post?
Step 1
Login to your WordPress dashboard and go to Plugins >> Add New using the menu in the left sidebar.
Step 2
Search for “Add Widget After Content”
Step 3
Install and Activate the plugin.
Step 4
Go to the plugin settings that appear under the Appearance subsection of the left sidebar menu.
By default, the widget will display on all posts but you can use the options available in the settings page to prevent the plugin from showing on specific types of post types and post formats.
Step 5
Once you have configured the settings of the plugin, just go to widgets to Appearance >> Widgets to add the content that you want to show at the end of each post.
You will see a widget area named “After Content”
You can add text, custom HTML, newsletter subscription forms, or any shortcodes in the widget area.
So now whatever you add in the widget area will automatically show after each post in WordPress.
Add Content after Post in WordPress without using plugin
This method makes use of what is known as WordPress Filter.
WordPress filters allow you to play with the WordPress functionality.
You can make changes to the WordPress functionality using it.
So to add content after post, you need to add the following code to the bottom of the functions.php file of your theme.
[code type=”javascript” linenums=”yes”]function auto_insert_after_post($content){if (is_single()) {
$content .= ‘The block of text you want to add goes here’;
}
return $content;
}
add_filter( “the_content”, “auto_insert_after_post” );[/code]
Note that if(is_single())
condition is used to make sure that this filter is only applied to single post pages. If this condition is not added then the code would be appended to all posts and pages. Also do not remove the single quote marks while editing the content.
Now just save the functions.php file and check out any post on your blog.
The content you have added to the code above will show at the end of the posts.
Bonus : Add Content before Post in WordPress without using plugin
Just as explained above to add content before each post, you need to add the following code to the bottom of the functions.php file of your theme.
[code type=”javascript” linenums=”yes”]function auto_insert_after_post($content){
$your_custom_text = ‘The block of text you want to add goes here’;
if (is_single()) {
$content = $your_custom_text.$content;
}
return $content;
}
add_filter( “the_content”, “auto_insert_after_post” );
Add Content after Post in Genesis Theme WordPress
Just as explained before to add content after each post in Genesis, you need to add the following code to the bottom of the functions.php file of Genesis child theme.
[code type=”javascript” linenums=”yes”]add_action( ‘genesis_entry_header’, ‘auto_insert_after_post’, 5 );
function auto_insert_after_post() {
if ( is_singular( ‘post’ ) ) :
echo ‘Your after post content here’;
endif;
}
Conclusion: How to Automatically Add Content After Post in WordPress?
So there you have it, these are the ways by which you can add content after each post in WordPress.
Of course this is not just limited to add custom text, there are many uses of this, for example, you could add your newsletter subscription, display ads, share your social media etc.
Which of these methods do you prefer? Or do you have another way? Drop a comment below and let us know.
How to upload APK file in WordPress (simple method)
Paddy says
This does not seem to work with Gutenberg?
admin says
Which of the above methods have you used? Let me know so that I can help you further.
Mark says
I can go to Appearance and see the “General” settings tab. However, I have yet to figure out where to post my content.
The widget is there at bottom of posts but how do I tell the widget what content I want to display? I have no options that I can see.
Alex says
Hi,
I realize this is a few years old now. I tried to use the following javascript as a test and I got this error:
JS:
function auto_insert_after_post($content){
if (is_single()) {
$content .= ‘Dinosaurs ruled the earth once and will again soon.’;
}
return $content;
}
add_filter( “the_content”, “auto_insert_after_post” );
Error:
Warning: Use of undefined constant “auto_insert_after_post” – assumed ‘“auto_insert_after_post”’ (this will throw an Error in a future version of PHP) in /home/customer/www/[URL]/public_html/wp-content/themes/divi_child/functions.php on line 9
Question: Is there a fix to this error?