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, 2 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: Ads
-
AuthorPosts
-
August 9, 2016 at 9:42 pm #244114
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?
August 10, 2016 at 2:45 am #244251Hi 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.
August 10, 2016 at 12:02 pm #244465Thanks 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 🙂
August 10, 2016 at 12:45 pm #244504Sorry, 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.
August 10, 2016 at 1:05 pm #244541Hi 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
August 10, 2016 at 3:50 pm #244645Hi 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
August 10, 2016 at 3:59 pm #244650Hi 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
August 10, 2016 at 5:55 pm #244717Hi Stiofan,
Thanks very much! That is very helpful. I’m working on it now.
John
August 10, 2016 at 5:56 pm #244719No probs 🙂
August 10, 2016 at 6:57 pm #244751Stiofan,
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,
JohnAugust 10, 2016 at 7:55 pm #244761Hi 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
August 10, 2016 at 10:09 pm #244827In 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>'; } } }
August 11, 2016 at 9:35 am #245054looks good to me, well done 🙂
August 11, 2016 at 12:36 pm #245126Stiofan, 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
August 11, 2016 at 12:39 pm #245130No 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
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket