{"id":1023,"date":"2013-08-24T05:36:00","date_gmt":"2013-08-24T05:36:00","guid":{"rendered":"http:\/\/www.arhixe.com\/?p=78"},"modified":"2013-08-24T05:36:00","modified_gmt":"2013-08-24T05:36:00","slug":"how-to-insert-adsense-ads-in-all-posts-in-a-wordpress-blog","status":"publish","type":"post","link":"https:\/\/thefaddism.com\/?p=1023","title":{"rendered":"How to Insert Adsense ads  in all Posts in a WordPress Blog"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"text-align: justify;\">When it comes to monetizing a WordPress  blog with ads under a post title or below the post or in between the  posts it is so simple to do with a plugin. If you have a blogger blog  then you need to open the template through blogger dashboard and can  embed the ad code. But in WordPress if you want to do it manually then  you need to spend some time with the functions.php file in your theme  page or else you need to manually place code in each and every post. If  you don\u2019t want to mess up things with a php code or waste your valuable  time by pasting the ad code in each and every post, then to ease your  efforts there is a simple plugin I would recommend which is called as <a href=\"http:\/\/wordpress.org\/plugins\/ad-injection\/\" target=\"_blank\" rel=\"noopener\">Ad injection<\/a> and don\u2019t worry this is a free plugin.<\/div>\n<h2 style=\"text-align: justify;\">Installing Ad injection:<\/h2>\n<div style=\"text-align: justify;\">All you need to do is search for <a href=\"http:\/\/wordpress.org\/plugins\/ad-injection\/\" target=\"_blank\" rel=\"noopener\">Ad injection<\/a> in the search plugins page and install this plugin and activate it.<\/div>\n<div style=\"text-align: justify;\"><a href=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-1.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ad injection How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" class=\"aligncenter size-full wp-image-1516\" height=\"402\" src=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-1.jpg\" title=\"How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" width=\"881\" \/><\/a><\/div>\n<h2 style=\"text-align: justify;\">Benefits of Ad Injection:<\/h2>\n<ul>\n<li style=\"text-align: justify;\">This plugin is not limited to only  adsense or few publishers you can add ad code from any publisher and  even you can add your own custom banner ad&nbsp;(e.g. Google AdSense, Amazon  Associates, ClickBank, TradeDoubler, etc).<\/li>\n<li style=\"text-align: justify;\">Have more control of random ads by exactly determining the number and placement.<\/li>\n<li style=\"text-align: justify;\">Can disable ads on few selected pages like Home, Archives, search, about us, contact us etc.<\/li>\n<li style=\"text-align: justify;\">Can handle CSS codes easily to float the ads to either left right or center.<\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\">Configuring Ads through Ad injection:<\/h2>\n<div style=\"text-align: justify;\">After installation you can get this  plugin in the settings page and when you click on it you will be  directed to the ad injection settings. Here you have a variety of option  to play with. First you would be having a widget where you have the  ability to enable and disable ads in whatever page you choose.<\/div>\n<div style=\"text-align: justify;\"><a href=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-2-1.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ad injection 2 How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" class=\"aligncenter size-full wp-image-1517\" height=\"584\" src=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-2-1.jpg\" title=\"How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" width=\"998\" \/><\/a><\/div>\n<div style=\"text-align: justify;\">In order to enable your Ads you need to click on the <b>On: Ads enabled<\/b><\/div>\n<div style=\"text-align: justify;\">If you want to disable Ads you can  select Off this is done when you are effected with click bombing. You  need not remove your ad code but simply you can check off and your Ads  won\u2019t be displayed.<\/div>\n<div style=\"text-align: justify;\">Third option is Test Mode where ads can  be visible only to admin so that he can test and see how ads look after  enabling them to display. After you feel the ads placements are good you  can enable them to all visitors.<\/div>\n<div style=\"text-align: justify;\"><a href=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-3-1.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ad injection 3 How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" class=\"aligncenter size-full wp-image-1519\" height=\"524\" src=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-3-1.jpg\" title=\"How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" width=\"676\" \/><\/a><\/div>\n<div style=\"text-align: justify;\"><span style=\"color: black;\">Immediately  after these three options you have an option called Tick to disable  ads. Here you can disable ads on pages like 404, home page, search page,  Archieve pages etc. So if you don\u2019t want your ads to be displayed on  your about us, Contact us, Privacy policy you can disable them by  checking the appropriate box. You can also disable only a particular ad  unit too it could be a top ad, bottom ad or even a random ad for a  particular page.<b><br \/><\/b><\/span><\/div>\n<div style=\"text-align: justify;\">Next you would have some more options  where you can select options like displaying ads only on posts which are  longer than 100 words, 200 words or as per your wish.<br \/><a href=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-4-1.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ad injection 4 How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" class=\"aligncenter size-full wp-image-1520\" height=\"531\" src=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection-4-1.jpg\" title=\"How to Insert Adsense ads Automatically in all Posts in a WordPress Blog\" width=\"666\" \/><\/a><br \/>You also have an option to set Maximum number of random ads per post.  Adsense and even few publishers support only 3 ad units or some four so  you can limit the random ads to 2 or 3 depending on the Terms of your  publisher. There are more options in this section which can be easily  understood.<\/div>\n<div style=\"text-align: justify;\">Immediately after the settings widget  you have the important widget where your adsense code or any other ad  code can be place. You can also adjust the placement by few options  given in the right side. You can float your ad left, right or center.  You can increase the margins or padding that all depends on how you want  your ad to look in the space.<\/div>\n<div style=\"text-align: justify;\">So there are four sections like Top ad  it displays ads immediately after the post title, Random ad which is  displayed randomly in between posts, bottom ad which displays ads below  the post content and footer ad which displays ads on your footer  section. Below these there are more options for an advanced user but for  a basic user the settings which I have discussed are more than enough.<\/div>\n<h2 style=\"text-align: justify;\">How to place ads without a Plugin:<\/h2>\n<div style=\"text-align: justify;\">If you want to place ads without using a  plugin then you need to go with this method where you need to open your  functions.php file of your theme and paste the following code.<\/div>\n<pre>&lt;?php<br \/><br \/>\/\/Insert ads after second paragraph of single post content.<br \/><br \/>add_filter( 'the_content', 'prefix_insert_post_ads' );<br \/><br \/>function prefix_insert_post_ads( $content ) {<br \/><br \/> $ad_code = '&lt;div&gt;<span style=\"color: red;\">Ad code goes here<\/span>&lt;\/div&gt;';<br \/><br \/> if ( is_single() &amp;&amp; ! is_admin() ) {<br \/>  return prefix_insert_after_paragraph( $ad_code, <span style=\"color: red;\">2<\/span>, $content );<br \/> }<br \/><br \/> return $content;<br \/>}<br \/><br \/>\/\/ Parent Function that makes the magic happen<br \/><br \/>function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {<br \/> $closing_p = '&lt;\/p&gt;';<br \/> $paragraphs = explode( $closing_p, $content );<br \/> foreach ($paragraphs as $index =&gt; $paragraph) {<br \/><br \/>  if ( trim( $paragraph ) ) {<br \/>   $paragraphs[$index] .= $closing_p;<br \/>  }<br \/><br \/>  if ( $paragraph_id == $index + 1 ) {<br \/>   $paragraphs[$index] .= $insertion;<br \/>  }<br \/> }<br \/><br \/> return implode( '', $paragraphs );<br \/>}<\/pre>\n<div style=\"text-align: justify;\">In the above code you need to place your  code where it says ad code goes here. If you want your ad code to be  displayed after third paragraph you need to change the number 2 which is  in red to number 3. Personally I use Ad injection plugin to configure  ads in my WordPress blog. There are also many plugins to insert ads like  <a href=\"http:\/\/wordpress.org\/plugins\/wp-insert\/\" target=\"_blank\" rel=\"noopener\">Wp-Insert<\/a> which also has almost same functions like ad injection. Now its up to you how you monetize your blog.<\/div>\n<p>Credits for Code: <a href=\"http:\/\/www.wpbeginner.com\/wp-tutorials\/how-to-insert-ads-within-your-post-content-in-wordpress\/\" target=\"_blank\" rel=\"noopener\">Wpbeginner<\/a> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to monetizing a WordPress blog with ads under a post title or&#8230;<\/p>\n","protected":false},"author":1,"featured_media":338,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,14],"tags":[],"class_list":["post-1023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adsense","category-blogger-guide"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Insert Adsense ads in all Posts in a WordPress Blog - The Faddism<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thefaddism.com\/?p=1023\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Insert Adsense ads in all Posts in a WordPress Blog - The Faddism\" \/>\n<meta property=\"og:description\" content=\"When it comes to monetizing a WordPress blog with ads under a post title or...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thefaddism.com\/?p=1023\" \/>\n<meta property=\"og:site_name\" content=\"The Faddism\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-24T05:36:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"881\" \/>\n\t<meta property=\"og:image:height\" content=\"402\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/thefaddism.com\/?p=1023\",\"url\":\"https:\/\/thefaddism.com\/?p=1023\",\"name\":\"How to Insert Adsense ads in all Posts in a WordPress Blog - The Faddism\",\"isPartOf\":{\"@id\":\"https:\/\/thefaddism.com\/#website\"},\"datePublished\":\"2013-08-24T05:36:00+00:00\",\"dateModified\":\"2013-08-24T05:36:00+00:00\",\"author\":{\"@id\":\"https:\/\/thefaddism.com\/#\/schema\/person\/1b84fda14e3b82a80ecb9c9da1f25c44\"},\"breadcrumb\":{\"@id\":\"https:\/\/thefaddism.com\/?p=1023#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/thefaddism.com\/?p=1023\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/thefaddism.com\/?p=1023#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/thefaddism.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Insert Adsense ads in all Posts in a WordPress Blog\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/thefaddism.com\/#website\",\"url\":\"https:\/\/thefaddism.com\/\",\"name\":\"The Faddism\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/thefaddism.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/thefaddism.com\/#\/schema\/person\/1b84fda14e3b82a80ecb9c9da1f25c44\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/thefaddism.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/597a6e8a8264cf7584d467c244a09bd9e6d1263b00a663bf0dd67049d64d97a8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/597a6e8a8264cf7584d467c244a09bd9e6d1263b00a663bf0dd67049d64d97a8?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/thefaddism.com\"],\"url\":\"https:\/\/thefaddism.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Insert Adsense ads in all Posts in a WordPress Blog - The Faddism","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thefaddism.com\/?p=1023","og_locale":"en_US","og_type":"article","og_title":"How to Insert Adsense ads in all Posts in a WordPress Blog - The Faddism","og_description":"When it comes to monetizing a WordPress blog with ads under a post title or...","og_url":"https:\/\/thefaddism.com\/?p=1023","og_site_name":"The Faddism","article_published_time":"2013-08-24T05:36:00+00:00","og_image":[{"width":881,"height":402,"url":"https:\/\/thefaddism.com\/wp-content\/uploads\/2013\/08\/ad-injection.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/thefaddism.com\/?p=1023","url":"https:\/\/thefaddism.com\/?p=1023","name":"How to Insert Adsense ads in all Posts in a WordPress Blog - The Faddism","isPartOf":{"@id":"https:\/\/thefaddism.com\/#website"},"datePublished":"2013-08-24T05:36:00+00:00","dateModified":"2013-08-24T05:36:00+00:00","author":{"@id":"https:\/\/thefaddism.com\/#\/schema\/person\/1b84fda14e3b82a80ecb9c9da1f25c44"},"breadcrumb":{"@id":"https:\/\/thefaddism.com\/?p=1023#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thefaddism.com\/?p=1023"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/thefaddism.com\/?p=1023#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thefaddism.com\/"},{"@type":"ListItem","position":2,"name":"How to Insert Adsense ads in all Posts in a WordPress Blog"}]},{"@type":"WebSite","@id":"https:\/\/thefaddism.com\/#website","url":"https:\/\/thefaddism.com\/","name":"The Faddism","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thefaddism.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/thefaddism.com\/#\/schema\/person\/1b84fda14e3b82a80ecb9c9da1f25c44","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thefaddism.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/597a6e8a8264cf7584d467c244a09bd9e6d1263b00a663bf0dd67049d64d97a8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/597a6e8a8264cf7584d467c244a09bd9e6d1263b00a663bf0dd67049d64d97a8?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/thefaddism.com"],"url":"https:\/\/thefaddism.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/thefaddism.com\/index.php?rest_route=\/wp\/v2\/posts\/1023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thefaddism.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thefaddism.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thefaddism.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thefaddism.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1023"}],"version-history":[{"count":0,"href":"https:\/\/thefaddism.com\/index.php?rest_route=\/wp\/v2\/posts\/1023\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thefaddism.com\/index.php?rest_route=\/wp\/v2\/media\/338"}],"wp:attachment":[{"href":"https:\/\/thefaddism.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thefaddism.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thefaddism.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}