1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Generatepress Adsense Settings

Discussion in 'WordPress' started by michael_jackson, Aug 2, 2021.

  1. #1
    hello experts,

    My client running an affiliate site, he wants to show his AdSense ads only on the blog section and posts.

    I have tried to run the below-mentioned code in theme editor → single.php and that didn't work for me.

    
    if (is_category( 'blog' );) {
    //do nothing
    } else {
    //show google ads
    }
    
    Code (markup):

    Please can anyone help out here
     
    Last edited: Aug 2, 2021
    michael_jackson, Aug 2, 2021 IP
  2. m.smit

    m.smit Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Advanced Ads plugin can help.
     
    m.smit, Aug 27, 2021 IP
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #3
    qwikad.com, Aug 27, 2021 IP
  4. michael_jackson

    michael_jackson Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    Thank you guys, but I did differently.
    1: Admin Panel -> Appearance ->Elements or you can click on GeneratePress -> Click on 2nd Tab (Elements)
    2: Click on Add New -> Choose Element Type, I selected "Hook"
    3: in the 2nd Section, I have inserted my Google ads code with the if-else condition.
    <?php if (in_category( 'blog' )) : ?>
    
    sidebar google ads code, it will show only in the blog section. site https://gotennisracquets.com
    
    <?php endif;?>
    Code (markup):
    4: where my Hook show, I selected "after_right_sidebar_content"
    5: Check Exclude PHP

    Display Rules
    1: Location -> Posts -> All posts
    2: All users

    This is all I did for showing my google ads in my blog section only in my GeneratePress theme.
     
    michael_jackson, Aug 28, 2021 IP
  5. Chill Bill

    Chill Bill Peon

    Messages:
    13
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Have you considered the official google wordpress plugin? It is by far the easiest way to get adSense running. Search the wordpress plugin directory for "Site Kit".
     
    Chill Bill, Aug 30, 2021 IP
  6. c1lonewolf

    c1lonewolf Member

    Messages:
    57
    Likes Received:
    21
    Best Answers:
    1
    Trophy Points:
    33
    #6
    I have tried to run the below-mentioned code in theme editor → single.php and that didn't work for me.

    
    if (is_category( 'blog' );) {
    //do nothing
    } else {
    //show google ads
    }
    
    Code (markup):
    
    if (is_category( 'blog' )) { /*show google ads*/ }
    
    Code (markup):
    note semicolon removed from original code
     
    c1lonewolf, Sep 1, 2021 IP
  7. dm35

    dm35 Well-Known Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    126
    #7
    I use Advanced Ads plugin. You can display by categories, specific pages, inside posts, etc Is very customizable
     
    dm35, Sep 4, 2021 IP