Community Forums › Forums › Archived Forums › Design Tips and Tricks › Disable Simple Hooks Code on landing page template (Prose theme)
Tagged: landing page, Prose theme, Simple Hooks
- This topic has 15 replies, 3 voices, and was last updated 11 years, 6 months ago by sheilam.
-
AuthorPosts
-
June 8, 2013 at 9:13 am #44755sheilamMember
Hi, I used simple hooks to add AdSense code to my site http://courtreportercareers.net/
However, I would like to disable the this code for the landing page as it contains my privacy policy. (which I put on the landing page template attempting to disable the code)
How can I eliminate the Adsense ads from my privacy policy page?
Thanks.
Sheila
http://courtreportercareers.net/June 8, 2013 at 9:32 am #44758rfmeierMemberHello,
Have you tried using WordPress Conditionals before you output the code within the hook callback?
Example;
function my_custom_callback(){ // if on home page, return if( is_home() ) return; // display your custom content }
I hope this helps.
June 8, 2013 at 9:57 am #44765Brad DaltonParticipantif (is_page_template('landing.php') ) }
or
if ( is_page('007') ) }
Replace 007 with the i.d for the landing page
June 8, 2013 at 1:21 pm #44801sheilamMemberThanks, Ryan and Brad, for the quick response.
I went to the link you provided, Ryan but, I am quite illiterate when it comes to coding! I am totally lost.
However, I can copy and paste!
Where in heavens would I put the code you're referring to, Ryan, and, Brad, do I replace the "if" line of code that Ryan suggests with the code you provided.
Thanks.
Sheila
June 8, 2013 at 2:10 pm #44804rfmeierMemberJune 8, 2013 at 2:46 pm #44810sheilamMemberRyan, I used:
`genesis_before` Hook
`genesis_before_content_sidebar_wrap` Hook
`genesis_after_content_sidebar_wrap` Hook
SheilaJune 8, 2013 at 2:55 pm #44812rfmeierMemberSheila,
Yes you would replace the code brad suggested within the if statement. So you could do something like this;
if( is_page_template( 'landing.php' ) ) return; // add your adsense code for display
So, if you current page is the landing page template, it will return (exit) and not display the adsense.
Make sure you check 'Execute PHP on this hook?'
Let me know how it works, we may have to tweak it a little.
June 8, 2013 at 4:53 pm #44827sheilamMemberHi Ryan,
I made multiple attempts and tweaks to get that code to work but all it did was display the code with the adsense.
I think that whatever I use may have to be inserted in the Custom Code or Custom CSS of this theme, Prose. And I did try that- still with no success.
Thanks,
Sheila
June 8, 2013 at 5:15 pm #44833rfmeierMemberJune 8, 2013 at 5:59 pm #44835sheilamMemberSure, I will just hide my ID.
Here it is:
<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxxxxxxxxxx";
/* Before Header */
google_ad_slot = "4381564314";
google_ad_width = 728;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Thanks for helping me with this!
Sheila
June 8, 2013 at 7:51 pm #44843rfmeierMemberSheila,
Looking back at one of your previous posts... You said it would just display the code. I did some quick testing and forgot to add the php tags.
<?php if( is_page_template( 'landing.php' ) ) return; // add your adsense code for display ?>
That will let the code be executed.
June 8, 2013 at 11:22 pm #44854Brad DaltonParticipantSheila
Here's a good tutorial on how to use conditional tags in Simple hooks http://designsbynickthegeek.com/tutorials/conditional-page-content
Another way to display Adsense in any genesis_hook position on single posts and exclude landing pages using conditional tags is to use a custom function.
Code not displaying? Grab it on Github.
Please copy the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor.
You can easily change the genesis_before_content_sidebar_wrap to another hook position
You can also use the new class (custom-content) to style your Adsense banners with padding etc.
June 8, 2013 at 11:41 pm #44856Brad DaltonParticipantOne more thing Sheila.
All custom code for Prose goes in the Genesis > Custom Code box rather than the child themes functions.php file.
If the code doesn't work when you save it in the Custom Code box, add it at the end of the lib/init.php file.
I tested this and it works in both however the Genesis > Custom Code box is the preferred place for adding custom PHP code.
What do you think Ryan?
June 9, 2013 at 6:22 am #44865sheilamMemberThanks, Brad and Ryan, for all of your assistance. But I am waving the white flag on this.
I made multiple attempts applying the suggested code and reading the info you recommended to no avail. I am afraid it is a beyond my expertise to correct this.
So, I removed the ad code in Simple Hooks. And, actually, my site looks less spammy because of it! 🙂
Again, thanks.
Shelia
June 9, 2013 at 9:05 am #44889rfmeierMemberFirst. Stupid me for having ad-block on while looking at your site. This whole time I was unable to see your ads. Geez-Louise!
Brad,
Good call on the Genesis Custom Code box. I agree is should be used over the plugin when possible.
Sheila,
If you still want to get this working, I could possibly wrap it up as a plugin for you. I cannot guarantee the timeframe to complete it, but I would be willing to help. You could contact me at [email protected] if you are still interested.
June 9, 2013 at 1:52 pm #44915sheilamMemberHi Ryan,
Thanks for 'fessing up ;D
And thanks for the offer for the plugin but I can go without it. I decided the site looks better without those link ads which I had installed via the simple hooks.
But, it would be nice to have an easy way to exclude simple hooks on specific pages/posts/templates- well, an easy way for those of us who are technically challenged!
Again, thank!
Sheila
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.