Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1020022
    helloeng
    Participant

    Hi, I found these 2 suggestions about how to mark new blog posts. Is this something that can be done with X-theme?

    https://wordpress.org/support/topic/highlight-new-posts-1?replies=4

    https://wordpress.org/support/topic/mark-new-posts-as-new?replies=4

    Can you please take a look?

    Thank you.

    #1020058
    Thai
    Moderator

    Hi There,

    Please add the following CSS under functions.php file locates in child theme:

    add_filter( 'post_class', 'x_post_class' );
    function x_post_class( $classes ){
      if( the_date('U', '', '', FALSE) >= (time() - (7 * 24 * 60 * 60)) ){
        $classes[] = "new-post";
      }
      return $classes;
    }

    After that you can add new custom CSS with this CSS class:

    .new-post {
    }

    Hope it helps 🙂

    #1021586
    helloeng
    Participant

    Hi thanks for answering.

    I tried it but it didn’t work. Here is what I used:

      X-child theme functions.php

    add_filter( ‘post_class’, ‘x_post_class’ );
    function x_post_class( $classes ){
    if( the_date(‘U’, ”, ”, FALSE) >= (time() – (7 * 24 * 60 * 60)) ){
    $classes[] = “new-post”;
    }
    return $classes;
    }

      x-child theme style.css

    .new-post {
    background: #feffdd;
    padding: 3px;
    border: 1px solid #eeefd2;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    margin-left:5px;
    font-size: small;
    font-weight: bold;
    }

    Technically, it should look like the attached screenshot.

    Any ideas why it didn’t work? do you see any errors in my code?

    #1021879
    Paul R
    Moderator

    Hi,

    To further assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1024040
    helloeng
    Participant
    This reply has been marked as private.
    #1024048
    helloeng
    Participant

    Hello again

    I don’t know why, but NOW it seems to work 😉

    see attached screenshot.

    Can you confirm? Do you see the color border around the June 3 post?

    Thanks.

    #1024059
    helloeng
    Participant

    However, I believe the above css should have resulted in the “NEW” sticker after the post title, as can be seen in the attached picture 😉

    Any ideas why it has a different effect on my site?

    #1024062
    helloeng
    Participant
    #1024555
    Jade
    Moderator

    Hi there,

    Yes, I am seeing the highlight for the recent post. It seems to be working fine because the CSS you have added will only add a border and a highlight color for the post area.

    #1025388
    helloeng
    Participant

    ok, thank you 😉

    #1025622
    Thai
    Moderator

    You’re most welcome 🙂

    If you need anything else please let us know.

  • <script> jQuery(function($){ $("#no-reply-1020022 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>