How to insert Google AdSense Ads in GeneratePress without Plugin?

Do you want to insert Google AdSense Ads in GeneratePress without Plugin? If yes then, you are on the right page.

There are many ways to insert Google AdSense Advertisement in WordPress using Plugin. But in this guide, we are going to insert Google AdSense code without a plugin.

Furthermore, you’ll learn

  • What is Google AdSense?
  • How to use GeneratePress Elements?
  • How to use Code Snippets?
  • Inserting Google AdSense in the GeneratePress Header.
  • Display Ads after Post Title.
  • Inserting Ads after content in a single post.
  • Adding AdSense between paragraph.
  • Setting Up Auto Ads in GP Theme.
  • Show Ads in the GeneratePress sidebar.
Insert Google AdSense Ads in GeneratePress without Plugin

What is Google AdSense?

Google AdSense is an advertising platform owned and maintained by Google that allows website owners to insert and display ads on their websites. Google helps creators to monetize their blog/websites with the AdSense.

Google AdSense Advertising Platform

AdSense is the number 1 advertising platform available on the internet that pay a good sum of money.

AdSense can be implemented on your website with the help of Auto Ads or can be placed manually. You can use display ads, text ads, matched content ads, etc in your blog/websites.

Insert Google AdSense Ads in GeneratePress Free Theme

If you are using a free version of the GP theme then you can find plenty of Google AdSense plugin to insert the AdSense Ads.

These are some free plugins available in the WordPress repository. You can find many more paid plugin too that helps to insert Google AdSense code.

I haven’t tested the plugin personally, so please read reviews about a plugin before implementing it on your site.

Insert Google AdSense Ads in GeneratePress without Plugin

I am using GeneratePress Premium Theme and I am writing this tutorial on the behalf of the premium theme. In GeneratePress Premium Theme, you can use the plugin method too but we are going to insert Advertisement code without any AdSense plugin.

In this method, we are going to use GeneratePress Premium Elements Modules. Let’s get started.

Adding a New Hook in GeneratePress
  • Go to Appearance > GeneratePress > Elements > Activate.
  • Go to Appearance > Elements > Add New.
  • Choose Element Type as Hook.
  • Add a Hook Title.
  • Follow the following Method.

Place AdSense Ads in GeneratePress Header

The header part of the site is a great place to show ads. Usually, we go for big banner ads in the header section of GP Theme. The best ad units to place in the header is Leaderboard Ads i.e. 728 x 90 also, you can try 970 x 90.

720 x 90 Leaderboard
970 x 90 Leaderboard
  • Go to AdSense > Ad > Ad Units > Display Ads
  • Go to Ad Size > Fixed Size > 728 x 90 or 970 x 90
  • Create an Ad and Copy the AdSense code.
  • Now, Go to Appearance > Elements
  • Choose Element Type as Hook.
  • Name a Hook.
  • Paste the AdSense code.
  • Now go to Elements Settings > Hook and choose after_header.
  • Go to Location and choose the Entire Site.
  • Hit Publish button.
Header Ads Elements in GeneratePress
Inserting Hook after_header in GeneratePress Theme
Display Rules in Entire Site in GeneratePress Theme

Now you can see the Ads in Header. In the same way, you can insert different ad networks code to display ads on your site.

Display AdSense Ads After Post Title in GeneratePress

Another popular and most widely used place to display AdSense Ads is after the post title on a single page. Here in GeneratePress, we are going to use Elements modules. Generally, I go with the Display Ads unit in AdSense.

Display AdSense Ads After Post Title in GeneratePress
  • Go to AdSense > Ad > Ad Units > Display Ads
  • Go to Ad Size > Responsive.
  • Create an Ad and Copy the AdSense code.
  • Now, Go to Appearance > Elements
  • Choose Element Type as Hook.
  • Name a Hook.
  • Paste the AdSense code.
  • Now go to Elements Settings > Hook and choose after_entry_title.
  • Go to Location and choose All Singular.
  • Hit Publish button.

Insert AdSense Ads After Entry Content in GeneratePress

Usually, I go with the link ad to place Ads after content in a single post but you can place any kind of Google AdSense Ads Unit.

Insert AdSense Ads After Entry Content in GeneratePress
  • Go to AdSense > Ad > Ad Units > Link Ads
  • Go to Ad Size > Responsive (Horizontal)
  • Create an Ad and Copy the AdSense code.
  • Now, Go to Appearance > Elements
  • Choose Element Type as Hook.
  • Name a Hook.
  • Paste the AdSense code.
  • Now go to Elements Settings > Hook and choose after_entry_content.
  • Go to Location and choose All Singular.
  • Hit Publish button.

Insert Ads in Between Content in GeneratePress

If you write long content then inserting Ads between certain paragraphs is always the best way to generate additional income.

Insert Ads in Between Content in GeneratePress WordPress

For this, you need to create a child theme and use the following code in functions.php or you can use a Code Snippets plugin. This plugin helps to insert code to functions.php without messing other codes.

Here we are going to insert AdSense code after the fourth paragraph. so Let’s display some ads using code in functions.php

  • Go to Plugins > Add New > Search
  • Search Code Snippets > Install > Activate
  • Code Snippets > Add New
  • Give a Title to a Snippet.
  • Paste the following Code and Hit Activate Button
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = ' Paste your AdSense Code Inside this quote';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 4, $content );
}
return $content;
}
// Parent Function that makes the magic happen
function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = '</p>';
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {
if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}
if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;
}
}
return implode( '', $paragraphs );
}

You can use the same code to display Ads by changing number 4th to 5th or others accordingly.

Setup Auto AdSense Ads in GeneratePress

If you don’t want to place manually and want one code to work everywhere in your site then Auto AdSense Ads is a great way to start. It is a set and forgets type of Ad. Auto Ads display Ads automatically wherever possible.

Auto AdSense Ads in GeneratePress Theme

so how to display auto AdSense ads in generatepress? Here is the method

  • Go to AdSense
  • Navigate Ads > Auto Ads
  • Click Setup Auto Ads
  • Copy the code snippet
  • Go to Appearance > Elements > Add New
  • Choose Element Type as Hook and Name it.
  • Paste the Auto Ads code
  • Go to Hook Settings and choose wp_head
  • Go to Display Rules, Choose Location as Entire Site and Exclude Page/All Pages.

Display AdSense Ads in GeneratePress sidebar

Generally, you can go with 300×250 or 300×600 ad sizes to show ads in the sidebar. The medium rectangular (300×250) ad size and Large Skyscraper (300×600) are the most popular and highest performing AdSense Ads units.

Display AdSense Ads in GeneratePress sidebar

So let’s display ads in the GeneratePress sidebar.

  • Go to AdSense > Ad > Ad Units > Display Ads
  • Go to Ad Size > Fixed Size > 300×250 or 300×600
  • Create an Ad and copy the AdSense code.
  • Go to Appearance > Widgets.
  • Add Text Widget to the sidebar.
  • Paste the code (Text Editor) and Hit Save button.

Conclusion

I think now you can insert Google AdSense Ads in GeneratePress without a plugin. If you are not familiar with code then you can use a plugin method to display Ads on your site.

Furthermore, if you have any questions/ideas then please feel free to comment below.

Get 100+ FREE SEO TOOLS

Quickly access over 100+ popular SEO,
Marketing tools to boost your website traffic.

Thank you for subscribing. Check your Email (Didn't receive? check spam folder)

Something went wrong.

I love all things having to do with WordPress, Digital Marketing, Social Media. Blogging has been my Passion. I'm interested in Literature and sometimes, loves to write.

2 thoughts on “How to insert Google AdSense Ads in GeneratePress without Plugin?”

  1. Hi, Suraj sir I want to create a child theme like yours using generatepress. Can you make a detailed guide on it? I have commented on your previous post but you didn’t reply to me. Plz, tell me if you can or not? Love from Maharashtra ❤️

    Reply
    • Hi Rakesh, I didn’t get your comment on my blog previously.
      Are you using free GeneratePress Theme or Paid one?
      If you are using Paid theme then you can get awesome support in GeneratePress Forum at generatepress.com/support
      If you are using free then you need to purchase the paid theme.

      Thank you.

      Reply

Leave a Comment

Download Brave Browser with AdblockerInstall Brave Now
+ +