Disable Simple Hooks Code on landing page template (Prose theme)

Community Forums Forums Design Tips and Tricks Disable Simple Hooks Code on landing page template (Prose theme)

This topic is: not resolved

This topic contains 15 replies, has 3 voices, and was last updated by  sheilam 10 months, 2 weeks ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #44755

    sheilam
    Participant
    Post count: 17

    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/
    #44758

    rfmeier
    Participant
    Post count: 518

    Hello,

    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.


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

    #44765

    braddalton
    Participant
    Post count: 7473
    if (is_page_template('landing.php') ) }
    

    or

    if ( is_page('007') ) }
    

    Replace 007 with the i.d for the landing page


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #44801

    sheilam
    Participant
    Post count: 17

    Thanks, 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

    #44804

    rfmeier
    Participant
    Post count: 518

    Sheila,

    What hook were you using in the Simple Hooks plugin?


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

    #44810

    sheilam
    Participant
    Post count: 17

    Ryan, I used:
    `genesis_before` Hook
    `genesis_before_content_sidebar_wrap` Hook
    `genesis_after_content_sidebar_wrap` Hook
    Sheila

    #44812

    rfmeier
    Participant
    Post count: 518

    Sheila,

    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.


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

    • This reply was modified 10 months, 2 weeks ago by  rfmeier.
    • This reply was modified 10 months, 2 weeks ago by  rfmeier.
    #44827

    sheilam
    Participant
    Post count: 17

    Hi 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

     

    #44833

    rfmeier
    Participant
    Post count: 518

    Sheila,

    Are you able to post you code that would display your adsense?


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

    #44835

    sheilam
    Participant
    Post count: 17

    Sure, 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

    #44843

    rfmeier
    Participant
    Post count: 518

    Sheila,

    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.


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

    #44854

    braddalton
    Participant
    Post count: 7473

    Sheila

    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.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #44856

    braddalton
    Participant
    Post count: 7473

    One 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?


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #44865

    sheilam
    Participant
    Post count: 17

    Thanks, 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

    #44889

    rfmeier
    Participant
    Post count: 518

    First. 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 rfmeier@gmail.com if you are still interested.


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

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

You must be logged in to reply to this topic.