Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1007001
    helloeng
    Participant

    Hi

    I saw this idea of marking new blog posts.
    http://www.wpbeginner.com/wp-themes/how-to-highlight-new-posts-for-returning-visitors-in-wordpress/

    1. I’ve tried the plugin mentioned in the article: https://wordpress.org/plugins/mark-new-posts/
    2. I’ve tried the php code below (in functions.php) and css

    But neither version worked.

    I’m using the latest version of X and CS.

    Can you help make this work? any suggestions?

    Thanks.

    // Mark New Posts
    //===============================================================================
    function wpb_lastvisit_the_title ( $title, $id ) {

    if ( !in_the_loop() || is_singular() || get_post_type( $id ) ==’page’ ) return $title;

    // if no cookie then just return the title

    if ( !isset($_COOKIE[‘lastvisit’]) || $_COOKIE[‘lastvisit’] ==” ) return $title;
    $lastvisit = $_COOKIE[‘lastvisit’];
    $publish_date = get_post_time( ‘U’, true, $id );
    if ($publish_date > $lastvisit) $title .= ‘<span class=”new-article”>New</span>’;
    return $title;

    }

    add_filter( ‘the_title’, ‘wpb_lastvisit_the_title’, 10, 2);

    // Set the lastvisit cookie

    function wpb_lastvisit_set_cookie() {

    if ( is_admin() ) return;
    $current = current_time( ‘timestamp’, 1);
    setcookie( ‘lastvisit’, $current, time()+60+60*24*7, COOKIEPATH, COOKIE_DOMAIN );
    }

    add_action( ‘init’, ‘wpb_lastvisit_set_cookie’ );

    CSS
    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;
    }

    #1007037
    Christian
    Moderator

    Hey there,

    Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

    Thank you for your understanding.

    #1007187
    helloeng
    Participant

    ok, thanks.

    #1007223
    Thai
    Moderator

    Thanks for understanding.

    If you need anything else please let us know.

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