Adding AdSense Code to bottom of Category pages

I know I can plug in my AdSense code to a widget area like the Primary sidebar or After Entry area.
However, I can't get any ads to show on category pages. I'm using the Genesis Framework. Is there a trick to this? I'd like to do it without installing a plug-in if possible.

  • Tyler Postle

    Hey Anne,

    Hope you're dong well today!

    You could place this code into your page.php template or single.php template:

    <?php if (is_category()) { ?>
    <p>insert ad code here</p>
    <?php } ?>

    That way it checks if it's a category page and if so then it inserts the ad code :slight_smile:

    You could also take advantage of the Genesis Simple Hooks plugin, you may already have it, and then do it this way: http://www.craigerson.com/adsense-genesis-framework/

    Hope this helps Anne! Let us know if you need any further assistance here.

    All the best,
    Tyler

    PS. Just wanted to let you know that we've just soft-launched our first 3 child themes built on our Upfront framework :slight_smile: it's been in development for 2 years and we're super excited to finally have it available to everyone. If you end up trying it out at all, let us know what you think! https://premium.wpmudev.org/projects/category/themes/

  • Anne

    Tyler,

    Using a plug-in called Helpful Information, it looks like my NewsPro theme uses the Genesis index.php file for category pages. So, I copied it into my theme folder and added the code above. The problem is I'm getting a parsing error which reads:

    Parse error: syntax error, unexpected '<' in C:\Users\Anne\Documents\Websites\www.timeatlas.dev\wp-content\themes\news-pro\index.php on line 18

    Any ideas?

  • Tyler Postle

    Hey Anne,

    Hope you're doing well today and thanks for your patience here.

    You don't need your opening <?php tag on line 18 because there is already one at the top :slight_smile:

    You can't have 2 opening php tags in a row, has to be a closing one in between them. Also, another option if you are only wanting the ads to show on the category archive pages: There should be a category.php or archive.php in your child theme. If it's just an archive.php then make a copy of it and re-name it to category.php and place the adsense in there :slight_smile: that template will only be used for category archive pages.

    If you would like me to take a closer look at this then do you mind sending in your FTP and WP login? :slight_smile:

    Send in:

    Subject: "Attn: Tyler Postle"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me :slight_smile:

    https://premium.wpmudev.org/contact/

    Look forward to hearing back!

    All the best,
    Tyler

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.