PHP<\/a> function as shown below.<\/p>\n\n\n\nfunction custom_insert_after_post( $content ) {\n\n if ( is_single() ) {\n\n $content .= 'The block of text will appear after every post or page';\n\n }\n\n return $content;\n\n}\nadd_filter( "the_content", "custom_insert_after_post" );<\/code><\/pre>\n\n\n\nThe code above should be added to the functions.php file in your theme. It is a PHP function that is called wherever the the_content()<\/code> WordPress function is encountered. It takes the content from the database as the input, appends custom text to it, then returns the modified content as its output.<\/p>\n\n\n\nThe above function will be applied on all pages, posts, and even archives, category feeds, etc. You can control where you would want the modified content to appear by adding additional checks. The example below checks if the_content() function is being called within the context of a single post and only then will it apply the custom modified content. If you want it to appear on a page you can change is_single()<\/code> to is_page()<\/code>.<\/p>\n\n\n\nfunction custom_insert_after_post( $content ) {\n\n if ( is_single() ) {\n\n $content .= 'The block of text will appear after every post but not page or archive feeds';\n\n }\n\n return $content;\n\n}\nadd_filter( "the_content", "custom_insert_after_post" );<\/code><\/pre>\n\n\n\nOnce you have finished editing, save the functions.php file and check out any post on your blog to confirm that update has been applied.<\/p>\n\n\n\n
Using Widget in WordPress Template File<\/h2>\n\n\n\n This method involves creating a new widget area and placing it at a preferred location after the post content. Even though we are including this method here, it may not be ideal as its placing can be bumped down the pecking order due to plugins invoking the the_content<\/code> filter and add content above yours.<\/p>\n\n\n\nTo proceed with this method here is what you need to do.<\/p>\n\n\n\n
First, create a new widget area using the register_sidebar()<\/code> function in the functions.php file. Here is a reference example.<\/p>\n\n\n\nregister_sidebar( array(\n 'name' => __( 'Add Content to Post Widget Area', 'mytheme' ),\n 'id' => 'add-content-sidebar',\n 'description' => __( 'The widget area to add content to the post', 'mytheme' ),\n 'before_widget' => '<div class="custom_widget_wrapper">',\n 'after_widget' => '<\/div>',\n 'before_title' => '<h2 class="custom_widget_title">',\n 'after_title' => '<\/h2>',\n) );<\/code><\/pre>\n\n\n\nThe code above will add a new widget area to the site. The content inserted into this widget area can be managed from the admin dashboard under Appearance<\/strong> > Widgets<\/strong>.<\/p>\n\n\n\nAdd this code to the appropriate theme template. In this case, you can add it to either singlular.php (for both posts and pages), page.php (only for pages), or single.php (only for single posts).<\/p>\n\n\n\n
if ( is_active_sidebar( 'add-content-sidebar' ) ) : \n \n dynamic_sidebar( 'add-content-sidebar' ); \n \nendif; <\/code><\/pre>\n\n\n\nYou will want to place it in the WordPress loop immediately after the call to the_content()<\/code>. Depending on the theme layout the location of the loop may differ from theme to theme.<\/p>\n\n\n\nConclusion<\/h2>\n\n\n\n There you have it. You now have the means to automatically add content after posts or pages using a widget created by a plugin or directly in your theme using the functions.php file. We have learned that using a plugin is the easiest and most flexible method while using the native WordPress feature may cause unforeseen problems that you did not intend.<\/p>\n\n\n\n
Again using a plugin is the only option above that is theme independent. This means you are not tied to your existing theme for this feature to work.<\/p>\n","protected":false},"excerpt":{"rendered":"
Have you ever wanted to automatically display standard content after each post or page in WordPress? Then you have come to the right tutorial. Here we will be showing you…<\/p>\n","protected":false},"author":1,"featured_media":11512,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,25,16,18],"tags":[101,142,320,350,424,433,449,452,460,544,581,591,635,651],"yoast_head":"\n
How to Automatically Add Content After Posts or Pages in WordPress<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n