How to Insert Any Content to the Bottom of Every Post in WordPress

  • Post last modified:Last updated on September 30, 2026
  • Post author:By

Adding content to your posts programmatically can be a real time saver. Maybe you need a disclosure notice under every article, a signup call-to-action, or a shortcode that should appear site-wide. Doing it by hand in dozens of posts is tedious — a few lines of code does it instantly and keeps working for every post you publish in the future.

In this guide, you’ll learn how to append content to every post using the the_content filter and a small code snippet.

How WordPress filters work

WordPress filters are hooks that let you modify a piece of data as WordPress processes it. Dozens of filters exist for different purposes — you’ll find them throughout the official developer documentation.

We’ll use the_content, the filter WordPress applies to a post’s body text after fetching it from the database and before printing it to the screen. It’s the perfect interception point for adding extra content to your posts.

Where to put the code

Don’t edit your parent theme’s functions.php directly — your changes will be wiped out the next time the theme updates. Instead, use one of these:

And as always: back up your site before touching code. A free backup plugin like UpdraftPlus takes minutes to set up.

Adding the code

Paste this at the end of your child theme’s functions.php (or your custom plugin file):

/**
 * Insert content after the post body.
 */
function gswp_insert_content_after_post_body( $content ) {
    if ( is_single() ) {
        $content .= '<p>This is inserted after the post body.</p>';
    }
    return $content;
}
add_filter( 'the_content', 'gswp_insert_content_after_post_body' );
How to Insert Any Content to the Bottom of Every Post in WordPress

How it works:

  • The function receives the post content, appends your HTML to it, and returns the result.
  • is_single() ensures it only runs on individual post pages — not your homepage, archives, or pages.
  • add_filter() attaches the function to the the_content filter.

Replace the <p>...</p> line with whatever you need — a disclosure, a newsletter signup, an author bio. To insert a shortcode instead of plain HTML, use:

$content .= do_shortcode( '[your_shortcode_here]' );

Test it

Open any single post on your site — your new content should appear right after the article body. If your site uses caching, clear the cache first or you may not see the change immediately.

That’s it — one snippet, and every current and future post gets your content automatically.

Adding content to your posts programmatically can be a real time saver. Maybe you need a disclosure notice under every article, a signup call-to-action, or a shortcode that should appear site-wide. Doing it by hand in dozens of posts is tedious — a few lines of code does it instantly and keeps working for every post you publish in the future.

Adding content to your posts programmatically can be a real time saver. Maybe you need a disclosure notice under every article, a signup call-to-action, or a shortcode that should appear site-wide. Doing it by hand in dozens of posts is tedious — a few lines of code does it instantly and keeps working for every post you publish in the future.

In this guide, you’ll learn how to append content to every post using the the_content filter and a small code snippet.

In this guide, you’ll learn how to append content to every post using the the_content filter and a small code snippet.

How WordPress filters work

WordPress filters are hooks that let you modify a piece of data as WordPress processes it. Dozens of filters exist for different purposes — you’ll find them throughout the official developer documentation.

WordPress filters are hooks that let you modify a piece of data as WordPress processes it. Dozens of filters exist for different purposes — you’ll find them throughout the official developer documentation.

We’ll use the_content, the filter WordPress applies to a post’s body text after fetching it from the database and before printing it to the screen. It’s the perfect interception point for adding extra content to your posts.

We’ll use the_content, the filter WordPress applies to a post’s body text after fetching it from the database and before printing it to the screen. It’s the perfect interception point for adding extra content to your posts.

Where to put the code

Don’t edit your parent theme’s functions.php directly — your changes will be wiped out the next time the theme updates. Instead, use one of these:

Don’t edit your parent theme’s functions.php directly — your changes will be wiped out the next time the theme updates. Instead, use one of these:

And as always: back up your site before touching code. A free backup plugin like UpdraftPlus takes minutes to set up.

And as always: back up your site before touching code. A free backup plugin like UpdraftPlus takes minutes to set up.

Adding the code

Paste this at the end of your child theme’s functions.php (or your custom plugin file):

/** * Insert content after the post body. */ function gswp_insert_content_after_post_body( $content ) { if ( is_single() ) { $content .= '<p>This is inserted after the post body.</p>'; } return $content; } add_filter( 'the_content', 'gswp_insert_content_after_post_body' ); 
How to Insert Any Content to the Bottom of Every Post in WordPress
How to Insert Any Content to the Bottom of Every Post in WordPress

How it works:

  • The function receives the post content, appends your HTML to it, and returns the result.
  • is_single() ensures it only runs on individual post pages — not your homepage, archives, or pages.
  • is_single() ensures it only runs on individual post pages — not your homepage, archives, or pages.
  • add_filter() attaches the function to the the_content filter.

Replace the <p>...</p> line with whatever you need — a disclosure, a newsletter signup, an author bio. To insert a shortcode instead of plain HTML, use:

Replace the <p>...</p> line with whatever you need — a disclosure, a newsletter signup, an author bio. To insert a shortcode instead of plain HTML, use:

$content .= do_shortcode( '[your_shortcode_here]' ); 

Test it

Open any single post on your site — your new content should appear right after the article body. If your site uses caching, clear the cache first or you may not see the change immediately.

Open any single post on your site — your new content should appear right after the article body. If your site uses caching, clear the cache first or you may not see the change immediately.

That’s it — one snippet, and every current and future post gets your content automatically.

Editorial Team

The GetStartedWP editorial team is a team of WordPress experts and developers. We are passionate about creating and sharing content like tutorials and guides about the entire WordPress ecosystem.

Disclousure: Our content is reader-supported. This means if you click on some of our links, then we may earn a small commission.

Leave a Reply