You need to enter ads in loop. Look at the content.php and other similar files for inserting ad code.
Remember that adsense do not allow more than 3 ads in single page.
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
Off topic for a minute:
@vneha44 Please stop inserting links to your own site in your replies. If you want to be assist people then please use the Codex links instead.
https://codex.wordpress.org/Main_Page
Thanks for the reply, @vneha44. Where exactly would I put the code? Pastebin for Twenty Fourteen content.php
Thanks for the heads up in regards to AdSense. How would I code it to only show up for, say, every third post?
Are you already using a child theme?
Yes, @esmi, as stated in the first post π
Try adding your code at the very bottom of content.php in your child theme.
Thanks, @esmi, that worked! I now have an ad showing at the bottom of each post (on the specific post page) and at the bottom of each post on the front page.
@vneha44 mentioned that some ad services don’t allow you to have more than e.g. 3 ads per page. An easy way to fix this would be to change the settings to only show 3 posts per page, but that’s not a lot of posts being shown.
Is there a way to only show the content (ads, in this example) for every n post – e.g. 3?
In order to do that, you would need to add a counter into index.php which was incremented in content.php and then used as a conditional in the same file to determine whether to show an ad or not. How comfortable are you with using PHP?
Thanks for taking your time, @esmi! π
I unfortunately can’t code PHP, but I have some experience modifying WordPress files – mostly through tutorials and trial and error.
Actually, I’ve come up with something a little more elegant. Have a look at http://pastebin.com/W6sxUrbG
Awesome, esmi. Thanks!!
Just to be difficult, is it possible to show the ad on the first post, and then every three? The reason I’m asking is the first solution would place an ad on single post pages as well, where as this solution only shows ads when there are multiple posts listed.
for single post, and 1st, 4th, 7th post (standard post format) in an index or archive, try:
<?php if( $wp_query->current_post%3 == 0 && (int)( $wp_query->current_post / 3 ) < 3 ) { ?>
ADSENSE CODE
<?php } ?>
for 2nd, 5th, 8th post, try:
<?php if( $wp_query->current_post%3 == 1 && (int)( $wp_query->current_post / 3 ) < 3 ) { ?>
ADSENSE CODE
<?php } ?>
for 3rd, 6th, 9th post, try:
<?php if( $wp_query->current_post%3 == 2 && (int)( $wp_query->current_post / 3 ) < 3 ) { ?>
ADSENSE CODE
<?php } ?>
Thanks, esmi and alchymyth – you guys are truly awesome!
Hi i have could sucessfully get the add code
but while placing the code in the text box in widget when clicked save it automatically changes to
<!– Beauty –>
<ins class=”adsbygoogle” style=”display:inline-block;width:250px;height:250px;”></ins>
(adsbygoogle = window.adsbygoogle || []).push({});
something like this and this code is displayed in my site
What m i doing wrong