How to Add Ads Within Your Post Content in WordPress
Do you want to incorporate advertising into your add ads WordPress post content? Your post content is where visitors are most engaged with your website, so it’s the ideal spot to display an ad. In this article, we will show you three different ways to insert advertising into your WordPress post text.
Why Add Ads to Your WordPress Post Content?
Banner and sidebar advertising are excellent ways to earn money while blogging with WordPress. However, they are also simple for tourists to overlook. People come to your site to read your content, and they may not pay as much attention to your sidebar or other parts of the page.
Because your post content receives the greatest attention from visitors, it’s an ideal spot to display advertisements. With that said, let’s take a look at three different methods to include adverts in your WordPress posts. If you want to move straight to a sure method, follow the links below.
Method 1. Inserting Add Ads to Within WordPress Post Content using WPCode (Automatically)
The free WPCode plugin allows you to place adverts within your post content.
WPCode is one of the greatest WordPress code snippet plugins available, as well as a top WordPress ad management plugin. It allows you to easily insert code to display advertisements on any page, post, or widget section of your WordPress website.
You can display add ads WordPress posts from third-party ad networks, such as Google AdSense. Alternatively, you can display your own hosted adverts, which are ideal for selling advertisements on your WordPress blog. To get started, install and activate the WPCode plugin. If you need support.
Once activated, click Code Snippets » + Add Snippet to your WordPress dashboard.
This will navigate you to the built-in code snippets library. Hover over the ‘Add Your Custom Code (New Snippet)‘ option, then click the ‘Use Snippet‘ button to select it.

Next, add a title for your ad in the section marked ‘Add title for snippet.’
Your site visitors will not see the title because it is exclusively for your reference.

Next, choose the type of ad you wish to display on your website. One alternative is to use the ad code generated by software such as Google AdSense. If you’re using Google AdSense code. We also have a comprehensive guide on how to maximize your AdSense revenue with WordPress.
Another alternative is to make your advertisement. In that situation, you’d have to receive the code from the person paying you to display the ad on your WordPress site or develop it yourself. Once you have the ad code, just copy and paste it into the ‘Code Preview‘ box.
In addition, select ‘HTML Snippet‘ as the ‘Code Type‘ from the dropdown box on the right side of the screen.

Next, scroll down to the ‘Insertion‘ section. There are two main insertion options to choose from:
- Auto-Insert – The ad code will be automatically put and performed on your website at the point you choose.
- Shortcode – The ad code will not be automatically inserted. You will receive a shortcode to manually insert anywhere on your WordPress blog.
To automatically display adverts within post content, use the ‘Auto-Insert‘ option.
Then, select ‘Insert After Paragraph‘ from the dropdown menu next to the ‘Location‘ field.

You can also change the ‘Insert Number’ to specify the number of paragraphs after which to insert the snippet. For example, if you want the ad to appear after the second paragraph rather than the first, simply change the 1 with a 2.
Aside from putting advertisements after paragraphs, you may also use WordPress functions to automatically display advertising before or after content, between posts, before or after excerpts, and more.

The premium edition of WPCode also allows you to insert advertising in WooCommerce locations such as before or after products, cart, and checkout pages, to mention a few.
WPCode Pro also allows you to arrange ad code snippets with start and stop dates. This is ideal for displaying advertisements throughout the holiday season or other limited-time promotions.
Next, scroll down to the ‘Device Type’ column. You can select whether to display your ad on all device types, desktop only, or mobile only.

To limit the pages or posts where the ad code snippet is automatically added, scroll down to the ‘Smart Conditional Logic‘ section. You can, for example, hide advertisements on specified page kinds or URLs.

To help set up your adverts, click on the ‘Basic info‘ section. In this section, you can include tags and comments to assist you in remembering what your ad code snippet is for.

When displaying multiple snippets in the same area, you may additionally regulate the order in which they are processed using the ‘Priority’ option.
All snippets have a priority of 10 by default, so if you want your ad code to appear before others, simply lower the priority.
When you’ve completed working on your advertisement, it’s time to post it.
To achieve this, return to the top of the page and change the switch from ‘Inactive’ to ‘Active‘. Then click the ‘Save Snippet‘ button.

That is it! If you used the ‘Auto-Insert‘ technique in this lesson, your ad will now be automatically integrated into your post text.
If you choose the ‘Shortcode‘ insertion method, you have the option of creating a new page or post or updating an existing one. Then, simply identify the exact location where you want this ad to appear within your post text and add a new shortcode block.
You can then insert the shortcode into this block. For step-by-step instructions, check our beginner’s guide on adding a shortcode to WordPress.
You can now go to the page or post and view the ad within the content.
Method 2: Inserting Add Ads Within WordPress Post Content Using Code (Advanced)
In WordPress, you can also use code to insert advertisements inside your article content.
Because you’re modifying your site’s code, this isn’t the most user-friendly way. However, it does allow you to create advertising without the need to install a separate ad management plugin.
To add an ad with code, open your theme’s functions.php file, create a site-specific plugin, or use a code snippets plugin.
Again, we choose the free WPCode plugin because it allows you to easily put snippets into WordPress without having to alter your theme’s functions.php file.
WPCode also includes clever code snippet checking to help you avoid common code problems and keep your site running smoothly.
//Insert ads after second paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = '<div>Ads code goes here</div>';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
return $content;
}
// Parent Function that makes the magic happen
function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = '</p>';
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {
if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}
if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;
}
}
return implode( '', $paragraphs );
}
This code displays an advertising following the second paragraph of a post’s content. If you wish to display your ad in a different spot, please update the following section:
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 3, $content );
}
In the sample code above, the ad is placed after the third paragraph.
Once you’ve done that, you may enter or paste your ad code. This is the code that determines how your ad appears and functions.
You’ll add this code as the $ad_code value, which is where it says ‘Add code goes here.’
$ad_code = '<div>Ads code goes here</div>';
After that, you’re ready to publish your advertisement. To accomplish this, either activate your site-specific plugin, save the changes you’ve made to your website’s functions.php file, or activate and save your code snippet in WPCode.
When you visit your website, you should see your ad live.
Also, Read More Relevant Blogs
- How to Fix WordPress Keeps Logging Out Problem
- What is an SEO Friendly URL Structure in WordPress
- How to Display Related Posts by the Same Author in WordPress
- How to Ask Google to Recrawl URLs of Your WordPress Site
- How to Easily Add JavaScript in WordPress Pages or Posts – 2 Methods
- How to Use User-Generated Content in WordPress to Grow Your Business
- How to Disable Theme and Plugin Editors from the WordPress Admin Panel
- How to Fix ‘Failed To Load Resource’ Error in WordPress
- How To Fix “The Link You Followed Has Expired” Error in WordPress
- How to Fix WordPress RSS Feed Errors (Step-by-Step Guide)
The Final Thought
Effectively integrating advertising into your add ads WordPress post content can greatly boost monetization efforts and revenue sources for your website. By strategically integrating advertisements within your material, you can attract your audience’s interest without interfering with their reading.
Remember to find a balance between adverts and quality content to ensure that your audience has a smooth and engaging browsing experience. Use plugins or manual insertion methods to effortlessly integrate advertising into your posts while following best practices and guidelines. With careful design and execution, you can optimize ad placement on your WordPress website to increase both user engagement and profit.
