{"id":41599,"date":"2014-07-27T16:16:41","date_gmt":"2014-07-27T10:46:41","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=41599"},"modified":"2020-05-24T11:06:46","modified_gmt":"2020-05-24T05:36:46","slug":"insert-adsense-ads-between-wordpress-posts","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/","title":{"rendered":"How to Insert Adsense Ads Between Posts in WordPress Blogs"},"content":{"rendered":"<p>How can you insert Adsense ads between posts on WordPress archives, categories, tags, \u00a0index, search and homepages. As you learnt about how to <a title=\"How to Add Adsense Ads in Middle of Blog Posts\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/12\/add-adsense-ads-middle-blog-posts\/\">insert Adsense inside articles<\/a>, inserting between WordPress post summary pages is a little different.<\/p>\n<h2>Insert Ads Between Posts in Archives<\/h2>\n<p>While editing your WordPress theme appearance, open <em><strong>index.php<\/strong><\/em> or <strong><em>archive.php<\/em><\/strong>. These files control the theme template for the homepage, index pages and archive pages (category and tags). The secret is to insert the Adsense code as seen on our site is below.<\/p>\n<pre><code>&lt;?php $postnum++; if(<strong>$postnum%5<\/strong> == 0) { ?&gt;\r\n&lt;style&gt;\r\n.responsive { width: 300px; height: 250px; }\r\n@media(min-width: 500px) { .responsive { width: 336px; height: 280px; } }\r\n&lt;\/style&gt;\r\n&lt;ins class=\"adsbygoogle yourclass\"\r\nstyle=\"display:inline-block\"\r\ndata-ad-client=\"ca-pub-12345678\"\r\ndata-ad-slot=\"12345678\"&gt;&lt;\/ins&gt;\r\n&lt;script&gt;\r\n(adsbygoogle = window.adsbygoogle || []).push({});\r\n&lt;\/script&gt;\r\n&lt;?php } ?&gt;<\/code><\/pre>\n<p>This code uses <a title=\"New Google Adsense Smart Sizing Responsive Ads\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/12\/new-google-adsense-smart-sizing-responsive-ads\/\">Adsense responsive unit<\/a>\u00a0to show small and large rectangle ads depending on the screen size. I had told you this large rectangle ad setting is the <a title=\"Change 300\u00d7250 Adsense Ads to 336\u00d7280 to Make More Money\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/change-adsense-ads-to-336x280\/\">highest paying combination<\/a> to target both 300x250px and 336x280px ads.<\/p>\n<h3>Add Adsense loader script once<\/h3>\n<p>It is best to <a title=\"Load Google Adsense Async Script Only Once for All Ad Units\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/07\/load-google-adsense-script-once\/\">load Adsense script once<\/a>. You can place it between the <em>&lt;HEAD&gt;<\/em> tags of your html code, such that it loads only once for multiple ad units. Since it uses <a title=\"Use Google Adsense Asynchronous Code for Faster Sites\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/google-adsense-asynchronous-code\/\">asynchronous adsense code<\/a>, it does not slow page loading time and can be used at the top the code.<\/p>\n<p><code>&lt;script <strong>async<\/strong> src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"&gt;&lt;\/script&gt;<\/code><\/p>\n<h3>Posts Per Page<\/h3>\n<p>The important thing to note here is you need to check how many post summaries you display on each category, tag or index pages. This can be done via <em>Settings &gt; Reading<\/em><\/p>\n<p><em><img decoding=\"async\" class=\"alignnone size-full wp-image-41601\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/archive-posts.png\" alt=\"archive posts number\" width=\"439\" height=\"253\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/archive-posts.png 439w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/archive-posts-150x86.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/archive-posts-300x172.png 300w\" sizes=\"(max-width: 439px) 100vw, 439px\" \/><\/em><\/p>\n<p>So you can choose how many post summaries to display on any such archive page. This example displays 8 post summaries on each page.<\/p>\n<h3>Display Multiple Adsense Ads<\/h3>\n<p>With code setting at\u00a0<code>$postnum%5<\/code>, it will insert an Adsense ad after <strong>every 5 posts.<\/strong> So if you have 8 posts displayed, it will display the ad only once on this page. Now it is your choice how many ads you want to display on a page. Note you cannot display more than 3 ad units per page.<\/p>\n<p>If you increase the posts per page to lets say 12, then this will display 2 ads, one after the 5 th post and one after the 10th post. Alternatively you can change the count code to\u00a0\u00a0<code>$postnum%3,\u00a0<\/code>which will cause the ads to load after 3 ads and so on.<\/p>\n<p>Here is how it will look like.<\/p>\n<p><img decoding=\"async\" class=\"border alignnone wp-image-41604 size-full\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/adsense-midads.png\" alt=\"adsense middle ads\" width=\"376\" height=\"554\" border=\"1\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/adsense-midads.png 376w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/adsense-midads-101x150.png 101w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/adsense-midads-203x300.png 203w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can you insert Adsense ads between posts on WordPress archives, categories, tags, \u00a0index, search and homepages. As you learnt&#8230;<\/p>\n","protected":false},"author":4,"featured_media":41604,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[13,49,17],"class_list":["post-41599","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","tag-adsense","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/41599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=41599"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/41599\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/41604"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=41599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=41599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=41599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}