{"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":"2026-10-08T19:11:24","modified_gmt":"2026-10-08T13:41:24","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 Archives"},"content":{"rendered":"<p>Your homepage, category, tag and search pages list many post summaries, and the space between them is a natural place for an ad. Here&#8217;s how to insert AdSense ads between posts in WordPress archive pages: with a few lines in your theme template, with a plugin, or automatically with Auto ads. This is different from <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/12\/add-adsense-ads-middle-blog-posts\/\">inserting AdSense inside articles<\/a>, because archive pages loop through many posts.<\/p>\n<p><strong>Quick answer:<\/strong> In your theme&#8217;s archive template (<code>index.php<\/code>, <code>archive.php<\/code> or the loop template part), add a check inside the WordPress loop such as <code>if ( ( $wp_query-&gt;current_post + 1 ) % 4 === 0 )<\/code> and output your AdSense ad code there. That shows an ad after every 4th post. Or use the Advanced Ads or Ad Inserter plugin, or AdSense <strong>In-feed ads<\/strong> and Auto ads, without touching code.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6aee09f83db52\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6aee09f83db52\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Method_1_Insert_AdSense_ads_between_posts_with_code\" >Method 1: Insert AdSense ads between posts with code<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Add_the_AdSense_script_once\" >Add the AdSense script once<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Check_how_many_posts_appear_per_page\" >Check how many posts appear per page<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Method_2_Use_a_plugin_no_code\" >Method 2: Use a plugin (no code)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Method_3_AdSense_In-feed_ads_and_Auto_ads\" >Method 3: AdSense In-feed ads and Auto ads<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Tips\" >Tips<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Frequently_asked_questions\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Is_there_still_a_limit_of_three_AdSense_ads_per_page\" >Is there still a limit of three AdSense ads per page?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Will_these_ads_show_on_single_posts\" >Will these ads show on single posts?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/07\/insert-adsense-ads-between-wordpress-posts\/#Do_In-feed_ads_earn_more_than_display_ads\" >Do In-feed ads earn more than display ads?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Method_1_Insert_AdSense_ads_between_posts_with_code\"><\/span>Method 1: Insert AdSense ads between posts with code<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Open your (child) theme&#8217;s archive template. Depending on the theme, the loop is in <code>index.php<\/code>, <code>archive.php<\/code>, <code>home.php<\/code>, or a template part like <code>template-parts\/content.php<\/code>. Inside the loop, after each post summary, add:<\/p>\n<pre><code>&lt;?php if ( ( $wp_query-&gt;current_post + 1 ) % 4 === 0 &amp;&amp; ! $wp_query-&gt;is_singular() ) : ?&gt;\r\n  &lt;div class=\"archive-ad\"&gt;\r\n    &lt;ins class=\"adsbygoogle\"\r\n         style=\"display:block\"\r\n         data-ad-client=\"ca-pub-XXXXXXXXXXXXXXXX\"\r\n         data-ad-slot=\"1234567890\"\r\n         data-ad-format=\"auto\"\r\n         data-full-width-responsive=\"true\"&gt;&lt;\/ins&gt;\r\n    &lt;script&gt;(adsbygoogle = window.adsbygoogle || []).push({});&lt;\/script&gt;\r\n  &lt;\/div&gt;\r\n&lt;?php endif; ?&gt;<\/code><\/pre>\n<p>Replace the client and slot IDs with your own from your AdSense account (<strong>Ads &gt; By ad unit<\/strong>). <code>$wp_query-&gt;current_post<\/code> starts at 0, so adding 1 and checking <code>% 4<\/code> inserts an ad after posts 4, 8, 12 and so on. Change 4 to place ads more or less often.<\/p>\n<p>In the original version of this tutorial we used a manual <code>$postnum++<\/code> counter and a fixed 300\u00d7250 \/ 336\u00d7280 ad. Today a responsive ad unit adapts to every screen, and WordPress&#8217;s built-in loop counter is simpler.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Add_the_AdSense_script_once\"><\/span>Add the AdSense script once<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Load the AdSense script just once in your site&#8217;s <code>&lt;head&gt;<\/code>, not with every ad. That&#8217;s faster, as we explained in <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/07\/load-google-adsense-script-once\/\">load the AdSense script once for multiple ads<\/a>:<\/p>\n<pre><code>&lt;script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXX\" crossorigin=\"anonymous\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>It&#8217;s <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/06\/google-adsense-asynchronous-code\/\">asynchronous<\/a>, so it doesn&#8217;t block your page from loading.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Check_how_many_posts_appear_per_page\"><\/span>Check how many posts appear per page<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Go to <strong>Settings &gt; Reading<\/strong> and check <strong>Blog pages show at most<\/strong>. With 8 posts per page and an ad every 4 posts, you get 2 ads per page.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41601\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/archive-posts.png\" alt=\"WordPress posts per page setting\" 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\" \/><\/p>\n<p>Here&#8217;s how ads between posts looked on our archive pages:<\/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 ads between posts in WordPress archives\" width=\"376\" height=\"554\" 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<p>AdSense used to limit you to three ad units per page. That rule was removed in 2016, but Google still requires that ads don&#8217;t outweigh your content, so keep a sensible balance.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_2_Use_a_plugin_no_code\"><\/span>Method 2: Use a plugin (no code)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/advanced-ads\/\" target=\"_blank\" rel=\"noopener\">Advanced Ads<\/a>: create an ad, then choose the <strong>Post lists<\/strong> placement and the position (for example, after the 4th post).<\/li>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/ad-inserter\/\" target=\"_blank\" rel=\"noopener\">Ad Inserter<\/a>: has a <strong>Between posts<\/strong> insertion option with paragraph and post counters.<\/li>\n<\/ul>\n<p>Plugins survive theme changes, which is a big advantage over editing templates.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_3_AdSense_In-feed_ads_and_Auto_ads\"><\/span>Method 3: AdSense In-feed ads and Auto ads<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>AdSense offers <strong>In-feed ads<\/strong>, designed to blend into lists of articles: create one under <strong>Ads &gt; By ad unit &gt; In-feed ads<\/strong> and use it in place of a display ad above. Or turn on <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2022\/12\/using-adsense-auto-ads\/\">AdSense Auto ads<\/a>, which automatically places ads on archive pages too. We use Auto ads on this site.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tips\"><\/span>Tips<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Keep ad slots a fixed minimum height with CSS to avoid layout shift as ads load.<\/li>\n<li>Don&#8217;t place ads where they could be mistaken for post links, which breaks AdSense policies.<\/li>\n<li>Hide unfilled slots cleanly; here&#8217;s how to <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2022\/03\/hide-unfilled-adsense-ad-spaces\/\">hide unfilled AdSense ad spaces<\/a>.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Is_there_still_a_limit_of_three_AdSense_ads_per_page\"><\/span>Is there still a limit of three AdSense ads per page?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>No. Google removed the three-ad limit in 2016. Instead, ads mustn&#8217;t exceed your content on the page.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Will_these_ads_show_on_single_posts\"><\/span>Will these ads show on single posts?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>No. The code runs only in archive loops. The <code>is_singular()<\/code> check makes sure of it.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Do_In-feed_ads_earn_more_than_display_ads\"><\/span>Do In-feed ads earn more than display ads?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It varies. In-feed ads match your post list style, which can improve clicks on archive pages. Test both and compare RPM.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your homepage, category, tag and search pages list many post summaries, and the space between them is a natural place&#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":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_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":1,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/41599\/revisions"}],"predecessor-version":[{"id":63663,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/41599\/revisions\/63663"}],"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}]}}