I was bored tonight and suddenly wanted to try adding ads to play.
In fact, in the early days, Hao VPS had Google ads, but it was banned... First of all, let me talk about the ad placement on the right side of my theme Prower V2. Find the rsidebar.php file and add it where you want to place ads: <li><h2>Sponsored ads</h2>, followed by the ad code (note that for the overall beauty of this theme, it is recommended to choose 250*250 ads )
Let’s talk about how to add ads to the article page:
1. Add surround ads to the WordPress log content page
Find the single.php file in the blog theme folder, and then open
to find this Snippet "php the_content" Insert the following code before this snippet:
<div style=”float:left; padding-bottom:10px;padding-top:10px;”>
Ad code
</div>
The key to implementation is float:left , which means floating to the left. If you like to be on the right, change it to right
. Please pay attention to the double quotes in the code. If there is no effect, check the double quotes!
2. Add ads at the bottom of the WordPress log content page
Add the ad code after <?php the_content(); ?>:
<?php the_content(); ?>
<div style=”padding:3px 0″>
Advertising code
</div>
3. Add advertisements at the top of the WordPress log content
. Open single.php and find php the_content(); add the advertisement code above php the_content();:
<div style=”padding:3px 0″>
Advertising code
</div>
<?php the_content(); ?>
4. Place Google adsense ads under the first article on the homepage of the blog:
You can find the index.php file under the currently used theme folder and find the following code php the_content(); insert the code in front of this code:
<?php if ($wp_query->current_post == 0) : ?>
<div style=”float:right; padding-bottom:10px;padding-top:10px;”>
Advertising Code
</div>
<?php endif; ?>
Insert after the code in php the_content();
<?php if ($wp_query->current_post == 0) : ?>
<div style=”padding-top:10px;text-align:center;”>
336*280 ad code
</div>
<?php endif; ?>
Haha, I guess it’s a bit difficult to make money from this, but I still got one to play with, it looks good~~
