Adding adsense unit under related listing
This topic contains 18 replies, has 3 voices, and was last updated by Guust 7 years, 1 month ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
January 6, 2018 at 11:34 am #411612
Hi
On my listing detail page I have about, photos, map, related listed in a list view. I would like to place an adsense code under the related listing. I saw the following code in the forum:add_action(‘geodir_after_detail_page_more_info’ , ‘add_adsense’, 10);
function add_adsense(){
echo “adsense code here”;
}but I do not know how to change this so that it goes under related listing. Also where do I place this code?
Thanks in advance!January 6, 2018 at 12:02 pm #411616That code will place “adsense code here” in the sidebar of the Detail page.
If you want to add adsense on the bottom of the Detail page, activate the bottom widget section and add a text widget with your code.
See https://wpgeodirectory.com/docs/layout/#directoryIf you want to use the above code, review https://wpgeodirectory.com/docs/useful-plugins/#snippets
Thanks
January 6, 2018 at 12:29 pm #411620Thanks for the quick reply. Ideally though I want the adsense to be contained within the actual listing. If I use the widget on the bottom it goes across the full width. If you look at my screen shot attached you will see where the adsense has gone and where I ideally would like it.
Thanks again for your help!January 6, 2018 at 12:35 pm #411623You can edit the template to move the bottom section to where you want it.
See https://wpgeodirectory.com/docs/customizing-geodirectory-templates/I’ll get a developer to have a look at your question too, there may be a hook for that.
January 6, 2018 at 12:39 pm #411627Hi
Yes that would be great thank you. I did create a html field (sceenshot attached) which will add it but it involves adding it each time to each listing – something I dont want. Not sure if there is a way of having this code always in there by default?January 6, 2018 at 12:40 pm #411629I’m not overly confident changing templates!
January 6, 2018 at 1:03 pm #411637Hello,
it would be possible to put it IN the related listings tab but i believe that is against the adsens T&C. If i’m not wrong the ad can’t be loaded in a hidden location, so unless u had the tabs showing as a list view it might not be the best idea.
Let me know what you want to do.
Thanks,
Stiofan
January 6, 2018 at 2:10 pm #411648Yes I do have it as a list view. I dont want it in the related listings but underneath it
January 6, 2018 at 3:06 pm #411659Not tested but something like this:
add_action('geodir_after_tab_content','_my_tab_content_after',10,1); function _my_tab_content_after($tab){ if($tab== 'related_listing'){ echo "adsense code here"; } }
Thanks,
Stiofan
January 6, 2018 at 3:36 pm #411665Apologies for my ignorance but where do I put that?
January 6, 2018 at 4:13 pm #411673No probs, the best way would be to use the code snippets plugin: https://wpgeodirectory.com/docs/useful-plugins/#snippets
Thanks,
Stiofan
January 13, 2018 at 1:01 pm #412626Hi again
Ive tried that and the plugin works great and goes where I want it but when I put the adsense code into the add function I get “The snippet has been deactivated due to an error on line 5:
syntax error, unexpected ‘Unit’ (T_STRING), expecting ‘(‘the adsense code is
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– Link Unit Responsive –>
<ins class=”adsbygoogle”
style=”display:block”
data-ad-client=”ca-pub-****************”
data-ad-slot=”***********”
data-ad-format=”link”></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>”;
}
}so the code I entered looks like:
add_action(‘geodir_after_tab_content’,’_my_tab_content_after’,10,1);
function _my_tab_content_after($tab){
if($tab== ‘related_listing’){
echo “<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– Link Unit Responsive –>
<ins class=”adsbygoogle”
style=”display:block”
data-ad-client=”ca-pub-****************”
data-ad-slot=”***********”
data-ad-format=”link”></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>”;
}
}I tried removing line 5 but then just got more error messages.
Any ideas?
Thanks again for your help, much appreciated!
January 13, 2018 at 10:56 pm #412686Make sure not to use curly quotes, try replacing all quotes by re-entering them using Code Snippets. Often when copying from somewhere else, the straight quotes changes to curly quotes.
If that does not work, please post your URL and WP admin details in a private reply and we will have a look.
Thanks
January 16, 2018 at 5:55 pm #413005Ive tried that but now I get
The snippet has been deactivated due to an error on line 1:
syntax error, unexpected ‘<‘January 16, 2018 at 6:50 pm #413011If that does not work, please post your URL and WP admin details in a private reply and we will have a look.
Stiofan
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket