Show Ads on Free Listings but not on Paid Listings?

This topic contains 16 replies, has 3 voices, and was last updated by  Stiofan O’Connor 8 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #244114

    John Els
    Expired Member
    Post count: 65

    I have the Payments Manager plugin installed and have created a Free listing package and three Paid listing packages. I would like to run Adsense ads on the Free listings in specific locations on the listing, but not on the Paid listings. I was thinking about placing an ad below the listing headline or above the tabbed section or at the bottom of the listing. How would you go about doing something like that?

    #244251

    Kor
    Moderator
    Post count: 16516

    Hi John,

    Unfortunately, this requires customization which falls outside the scope of what we offer for support. I’d suggest that you find a developer that could help with this or with a 3rd party plugin.

    #244465

    John Els
    Expired Member
    Post count: 65

    Thanks for the reply, Kor. Are there any GD hooks or functions that I can look at to try to implement this? While I’m not an expert on WP coding, I have written a line or two of PHP code and may be able to implement this myself. I’m just not familiar with GD’s hooks and functions. Thanks 🙂

    #244504

    John Els
    Expired Member
    Post count: 65

    Sorry, I should have added this to my last reply:

    Are there functions or hooks that I can use to:

    1. Identify the CPT being loaded?
    2. Identify the price package for the listing being loaded?
    3. Identify each section of a listing page being loaded?

    I’m thinking that if I can identify those items while a listing detail page is being loaded, I can insert ad code on the desired pages and at the desired locations.

    #244541

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi John,

    The simplest way is probably to add the package id class to the body then you can just hide anything u want.

    Thanks,

    Stiofan

    #244645

    John Els
    Expired Member
    Post count: 65

    Hi Stiofan,

    Thanks for that. I’m not 100% sure how to take that further, but it is giving me a clue. I’m going to have to do a little learning here, but hopefully I’m up to the challenge and can pull a rabbit out of the hat.

    Thanks again!

    John

    #244650

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi John,

    You would add that code to your child theme functions.php file and then basically if you have free premium with id=5 then the body of the page will have a class of “gd-package-id-5” so you can manipulate anything on the page for that package id only so you could just a CSS rule to hide any ads on that package id like

    .gd-package-id-5 .google-ads-wrapper{
    display:none;
    }

    Stiofan

    #244717

    John Els
    Expired Member
    Post count: 65

    Hi Stiofan,

    Thanks very much! That is very helpful. I’m working on it now.

    John

    #244719

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    No probs 🙂

    #244751

    John Els
    Expired Member
    Post count: 65

    Stiofan,

    I have something working now, but it’s just in the wrong location. I tested with geodir_before_detail_page_more_info, which drops it in the sidebar.

    Can you tell me if there is an Action that will let me drop some content between the taxonomies output and the tabs on the detail page? What about an Action that will drop content below the tabs?

    Thanks,
    John

    #244761

    John Els
    Expired Member
    Post count: 65

    Hi Stiofan,

    It looks like I found the Actions I was looking for. geodir_before_tab_list drops content directly above the tabs. geodir_after_single_post drops content below the tabs, at the bottom of that section of the page. Is there any reason that you can think of that would make those two Actions unsuitable?

    Now I only have to implement the filtering by package ID.

    Thanks for your help. This is awesome!

    John

    #244827

    John Els
    Expired Member
    Post count: 65

    In the end, this code below did the trick. It only inserts ads when the package ID is 7, 8, or 9 (my free packages). The ad code just goes directly in the code, i.e. no admin UI. I created two of these functions and stuck them in a plugin. It seems to work fine. If you see anything in this code that is bad practice, or something I overlooked, please let me know.

    
    
    add_action( 'geodir_before_tab_list', 'insert_ad_above_tabs', 10, 0 );
    function insert_ad_above_tabs() {
    	global $post;
    	$adcode = 'MY AD CODE HERE';
    	if (geodir_is_page('detail') && isset($post->package_id)) {
    		if ($post->package_id == 7 || $post->package_id == 8 || $post->package_id == 9) {
    			echo '<div class="ad-above-tabs">'.$adcode.'</div>';
    		}
    	}
    }
    #245054

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    looks good to me, well done 🙂

    #245126

    John Els
    Expired Member
    Post count: 65

    Stiofan, thanks for your help with this. That piece of code that you posted, got me started in the right direction. In the end, I learned something new about WordPress too.

    Have a great day 🙂

    John

    #245130

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    No problem John, i was trying to go the easy route but you seem to have some code knowledge 🙂

    If you haven’t already it would be great if you could leave us a review on wp.org, it really helps GD grow: https://wordpress.org/support/view/plugin-reviews/geodirectory

    Thanks,

    Stiofan

Viewing 15 posts - 1 through 15 (of 17 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount