Remove a note based on date

Community Forums Forums Design Tips and Tricks Remove a note based on date

This topic is: not resolved

This topic contains 6 replies, has 3 voices, and was last updated by  SelenaD 4 months, 1 week ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #110449

    SelenaD
    Participant
    Post count: 28

    I have added a note to the bottom of the comment form using the following code:

    // Add required text to bottom of comment form
    add_action (‘genesis_after_comment_form’, ‘required_text_note’);
    function required_text_note () {

    if ( is_single() && comments_open()) {
    ?>
    <div class=”required_text_note”>
    <p class=”required”>*</p><p class=”required_note”>Required field</p>
    </div>
    <?php
    }
    }

    This works great, except when comments are set to close after 14 days. Then the comment form goes away, but my note remains. How can I make the note disappear at the same time as the comments form?

    http://delaplex.com
    #110458

    Lauren @ OnceCoupled
    Member
    Post count: 616

    How are you with PHP? You could grab the publish date and compare it to the current date, then only show when the different is less than 14 days. Here’s some links on that information:

    http://www.php.net//manual/en/function.date.php

    http://codex.wordpress.org/Function_Reference/the_date

    Best,
    Lauren


    I do custom WordPress work! http://oncecoupled.com
    Contact me directly: lauren@oncecoupled.com

    #110460

    braddalton
    Participant
    Post count: 10337

    I think what you need is something like a conditional tag used by the comment system which only displays your text for 14 days after the post is published.


    #110468

    braddalton
    Participant
    Post count: 10337

    Another option is to change the hook so the note disappears when the form does by using a hook that executes within the comment form like comments note after. http://wpsites.net/web-design/modify-text-before-after-comment-form/


    #110486

    Lauren @ OnceCoupled
    Member
    Post count: 616

    Ooh, I like that second option. Here am I, making life difficult for you Selena! ;)


    I do custom WordPress work! http://oncecoupled.com
    Contact me directly: lauren@oncecoupled.com

    #110490

    braddalton
    Participant
    Post count: 10337

    Where did you post the code?

    No need to use opening and closing PHP tags for custom functions.

    Try this code which i tested:

    https://gist.github.com/braddalton/6db753679867f6c6fcd0


    #110563

    SelenaD
    Participant
    Post count: 28

    So I’m extremely ashamed to admit this, but you guys have been so helpful while I slept on the problem, that I have to confess. The original code I posted works – which uses the comments_open conditional tag. :-/ I was in the wrong client function file. And no matter how many times I changed the wrong functions file nothing was happening on the site in question. Hanging my head in shame.

    Thank you both for your efforts, and Brad, for telling me you had tested your code, because I might never have noticed otherwise. I knew it SHOULD work. Sorry to waste your time, but thanks as always for your help.

    LOVE you folks on Studiopress forums.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.