Forums

Modify Google Ad on Post using Custom Field (2 posts)

  1. Green Drinks Rhondda Cynon Taf
    Member
    Posted 5 years ago #

    I want to be able to modify the Google Advert used in the sidebar of a post so that the Google Advert size roughly corresponds with the size of the post.

    Is there some way to do this using a custom field, which is evaluated and then a Google Advert is chosen based on that custom field ?

    As an example, this post could do with a bigger google ad ...

  2. xdesi
    Member
    Posted 5 years ago #

    Well one option you could do is on your single.php add this after the loop:

    $adlong = get_post_meta($post->ID, 'AdsenseL', $single = true);

    and then in sidebar.php put:

    <?php

    if($adlong !== '') { ?>

    Code for Long Adsense AD

    <?php }
    else { ?>

    Code for Short Adsense Ad

    <?php}?>

    and the in custom field call it AdsenseL and just put Yes in the value and it will display a long ad if this key isnt present it will display short ad.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.