• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Gokul Deepak

Gokul Deepak

GoCool and Debug

  • Home
  • Terraform
  • WordPress
  • Android
  • How to
  • About Me

WordPress – Display Ads only on posts not on pages

June 15, 2021 by Gokul Deepak S Leave a Comment

We may want to display ads on our WordPress website. While coming for customization we would be having many troubles.

Target: To show ads only on posts and not on pages

What do we need: WordPress website, Genesis Theme, Genesis Hook plugin

Solution:

  1. Install Genesis Hook Plugin from the plugins repository
  2. Go to Genesis -> Genesis Hook from the side menu in wordpress admin console
  3. Choose the place where you are going to place the ad. Let us consider you want to display the ad below the Header. So paste the below code under Genesis_after_head section
<?php if (!is_page()) {  ?>
<!-- Your Scripts -->
</script>
<?php } ?>

For example we have pasted the google adsense code

<?php if (!is_page()) {  ?>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- GokulDeepak SideBar -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxx62423435"
     data-ad-slot="25xxxxxxxxxxxx"
     data-ad-format="link"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php } ?>

Filed Under: Wordpress

About Gokul Deepak S

Leave a ReplyCancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular Pages

  • Home
  • How to find the date of the Facebook group it was created
  • How to Remove LinkWithin logo under 'You Might Also Like' widget in blogger
  • Yureka Yu Plus vs Lenovo K3 Note
  • How to Install Windows without GRUB rescue

Archives

Categories

  • Android
  • Apache
  • AWS
  • Blogger
  • Computer Tips
  • DevOps
  • Docker
  • Earn
  • Facebook Tips
  • Git
  • Google Tips
  • Hosting
  • How to
  • Laptop Tips
  • Laptops
  • Linux
  • Mobile
  • MongoDB
  • Nginx
  • Node JS
  • Notepad++
  • PostgresQL
  • Terraform
  • Ubuntu
  • Wordpress
  • Xenforo

Tags

Android Android One AWS Bluehost Comparisions Custom ROM Elementor Facebook Genesis Genesis Sample Theme Google Drive How to Lineage OS Notes OnePlus One OwnCloud Rooting Smartphones Stock ROM Studiopress Tomcat Wordpress plugin

Copyright © 2025 ยท Maintained by GokulDeepak

wpDiscuz
 

Loading Comments...