Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] How to add adsense ads inside posts or articles

Home Forums Support How to add adsense ads inside posts or articles

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #141435
    JAGDEEP

    Hello Tom ,
    i love your generate press theme its easy and responsive, i want to know two things about it
    1. How to add adsense ads inside posts ? ( adsense ads are working well on my website)
    by adding a shortcode inside it please give proper details where to add the adsense code in theme also
    2. if i want to add a banner on homepage only , how it is possible ?

    #141472
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    1. You could use a plugin like this: https://wordpress.org/plugins/ad-inserter/

    Alternatively, you can place your Adsense code inside a shortcode and then use the shortcode.

    function generate_adsense_shortcode() {
    ?>
        Place your adsense code in here
    <?php }
    add_shortcode( 'adsense', 'generate_adsense_shortcode' );

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    Then you would use the [adsense] shortcode in your content.

    2. Where would you want the banner to appear? You could use our GP Hooks add-on, and then use this if conditional:

    <?php if ( is_front_page() ) : ?>
        Everything in here will only show up on the homepage
    <?php endif; ?>

    Then check the “Execute PHP” checkbox and you should be good to go 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.