[Resolved] PHP Script for Disclaimer in GP Hook

Home Forums Support [Resolved] PHP Script for Disclaimer in GP Hook

Home Forums Support PHP Script for Disclaimer in GP Hook

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #138621
    Stacy Fout

    I have a disclaimer on my site that I have placed in my GP Hooks to show up after entry title of the post. I like it there, but I don’t want it on every post. It looks like a way to fix that would be to execute PHP script. I put all deal-type posts in one category. Is there a way to write PHP script that would show the disclaimer on only posts in that particular category?

    While we’re on the subject, it would also be great to get it excluded from the front page teaser. Right now, I only include the title, featured image and a tag for read more on each post so the only text readers see is the title and a disclaimer right under my byline. Kind of a turn off. My site is mommado.com if you want to see what I am talking about.

    Thanks in advance for the help.

    Stacy

    #138639
    bdbrown

    Hi Stacy. In your hook you could do this; make sure to check the Execute PHP box. Change the category ID to your category:

    <?php
        if (in_category( '3' )) {
            echo 'your disclaimer here';
        }
    ?> 
    

    Adding this to your child theme css will hide the disclaimer on the home page posts:

    .home .inside-article sub {
        display: none;
    }
    

    But first you need to fix a couple of things in your child theme css.

    .page-header-image-single {
          text-align: center;
    }
    .page-header-image-single {
          display: none;
       <-------------------- missing a closing bracket here
    
    a {
    color: #324cc0;
    }
    
    a:hover {
    color: #333333;
    }
    

    And not sure why all this is in your css file; should be removed:

    Other Options –
    a:link
    a:visited
    a:active
    
    <script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us11.list-manage.com","uuid":"cad522133eccd68f256285159","lid":"efc38a70ec"}) })</script>
    
    #139546
    Stacy Fout

    Thanks so much for the reply. I edited my CSS to get it excluded from the front page; it worked great. I also took out the extra tidbits. I think I threw that Mailchimp stuff in there for my newsletter RSS feed… think being the operative word.

    I have not, as of yet, been able to get the category exclusion to work. I am not sure if it is because I added the extra subtext code or if I am mistyping your code. Sorry, rookie here.

    This is what I have under the GP for After Entry Title:

    <?php
    if (in_category( ‘MommaDoes: Deals’ )) {
    echo ‘<sub>This MommaDoes: Deals post was hand-picked by Stacy. The links in the post below may be affiliate links. Read the full disclosure.</sub>’;
    }
    ?>

    #139697
    bdbrown

    Glad the home page fix is working. The disclaimer is displayed on the following posts, all of which have a class of “category-deals”:

    http://mommado.com/today-only-40-off-cartwheel-savings-on-costumes/
    http://mommado.com/crazy-8-2-88-clearance-deals/
    http://mommado.com/texas-sized-savings-for-the-texas-state-fair/

    Is that not what you were trying to accomplish?

    #139709
    Stacy Fout

    Yes, that is exactly what I was trying to accomplish. I swear when I looked at a few posts yesterday in other categories, it was still showing the disclaimer on those as well. Today, though, it is only showing on disclaimers. Not sure why it wasn’t that way yesterday, but either way it’s perfect! Thanks so much for the assist.

    #139744
    bdbrown

    Maybe there was a cache that was updated overnight? In any case, glad it’s working and you’re welcome 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.