How to insert an ad unit between posts in WordPress

google AdSense ad units on a site is one of the most common ways to monetize your resource. Your earnings will depend on site traffic , on the location and format of the ad unit, as well as on the relevance of the offer to the visitor.

The format and location of advertising is one of the significant factors affecting the level of income from this type of monetization.

The easiest way is to place the ad unit in the most visible place, but visitors should not forget. Advertising should not interfere with normal use of navigation or take up more space than useful content.

We recommend that you pay more attention to how well-designed the content is, whether the ad interferes with its format or content to consume the main content of the site.

BLOG FOR WEBMASTERS

WordPress

 

For blogs and article sites on WordPress, the area between posts is one of the most clickable and prominent places.

In order to advertise between WordPress blog posts, you need to make small changes to your theme files.

I recommend that before any changes on the site, backup copies of the modified files. This will allow you to restore the site to work if, after editing the code, something went wrong.

Open: / wp-content / themes / your theme / or in the website control panel open Appearance – Editor . Next we will need the index.php file . We find:

<? php if (have_posts ()): while (have_posts ()): the_post (); ?>
this line needs to be replaced with the following code:

<? php $ postcount = 0; ?>
<? php if (have_posts ()): while (have_posts ()): the_post (); ?>
<? php $ postcount ++; ?>
But the process does not end there. Now you need to find:

<? php endwhile; endif; ?>
Before the found line, insert the code:

<? php if ($ postcount == 1) {?>
your ad unit code
<? }?>

The number 1 in the first line of code indicates that the ad unit will be broadcast after the first post on the main page.

For the heading, everything is the same, only changes are made in another file – archive.php .

If you upgrade your WordPress theme, the code changes will need to be repeated.

This is an easy and quick way to insert ad units between posts on the home page and in the headings for WordPress blogs. You can also use special plugins, but this is not always justified.

Read More: Fresh New Article

Read More: Top 10 best smartphones have been announced 2020

Read More: Call of Duty Modern Warfare third season new features Leaked

How to insert an ad unit between posts in WordPress
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

TRENDING STORY

To Top