• Resolved quaglia37

    (@quaglia37)


    Congratulations on the wonderful plugin
    Can I enter the date for each post shown?
    There is a style in which posts rotate continuously as in breaking news

    Thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Benaceur

    (@benaceur)

    If I understand correctly, you want to add the date of post before or after the title? If so, which animation is selected

    Thread Starter quaglia37

    (@quaglia37)

    I want to add the date before the title, scroll left animation
    Thank you

    Plugin Author Benaceur

    (@benaceur)

    first: update the plugin to last version 2.5.6
    after: put this code in functions.php file of your active theme:

    function ben_ntb_funct_filter_title( $string, $ntb ) {
    	// filter title news-ticker-benaceur https://benaceur-php.com/?p=1747
    	# 'd M Y H-i'| d/m/Y H-i
    	$d = '<div class="ben_ntb_funct_filter_title"><div class="ben_ntb_funct_filter_title-str s1">';
        $d .= date_i18n( 'd/m/Y', strtotime( $ntb[0] ) );
    	$d .= '</div>';
    
        return $d.'<div class="ben_ntb_funct_filter_title-str">'.$string.'</div></div>';
    }
    add_filter( 'ntb_title_filter_ben', 'ben_ntb_funct_filter_title', 10, 3 );
    
    function ben_ntb_funct_filter_title_style() {
    	echo '<style>
    	.ben_ntb_funct_filter_title-str.s1 {color:red;font-weight: bold;font-size: 12px;padding:0 3px;} 
    	.ben_ntb_funct_filter_title .ben_ntb_funct_filter_title-str {display:inline-block;}
    	</style>';
    }
    add_action( 'wp_head', 'ben_ntb_funct_filter_title_style' );

    To display the author change this line:
    $d .= date_i18n( 'd/m/Y', strtotime( $ntb[0] ) );
    to:
    $d .= $ntb[1];
    and to display the post modification date change to:
    $d .= date_i18n( 'd/m/Y', strtotime( $ntb[2] ) );
    and to display comment count change to:
    $d .= $ntb[3];
    To change the format of the date see this post:
    https://codex.www.ads-software.com/Formatting_Date_and_Time
    example:
    change this ‘d/m/Y’ to ‘d M Y H-i’

    Plugin Author Benaceur

    (@benaceur)

    and this without style:

    function ben_ntb_funct_filter_title( $string, $ntb ) {
    	// filter title news-ticker-benaceur https://benaceur-php.com/?p=1747
        $d = date_i18n( 'd/m/Y', strtotime( $ntb[0] ) );
    
        return $d.': '.$string;
    }
    add_filter( 'ntb_title_filter_ben', 'ben_ntb_funct_filter_title', 10, 3 );

    or:

    return '[ '.$d.' ] '.$string;
    or number of comments:

    function ben_ntb_funct_filter_title( $string, $ntb ) {
    	// filter title news-ticker-benaceur https://benaceur-php.com/?p=1747
        $d = $ntb[3];
    
        return '[ comment(s): '.$d.' ] '.$string;
    }
    add_filter( 'ntb_title_filter_ben', 'ben_ntb_funct_filter_title', 10, 3 );

    author:

    function ben_ntb_funct_filter_title( $string, $ntb ) {
    	// filter title news-ticker-benaceur https://benaceur-php.com/?p=1747
        $d = $ntb[1];
    
        return '[ author: '.$d.' ] '.$string;
    }
    add_filter( 'ntb_title_filter_ben', 'ben_ntb_funct_filter_title', 10, 3 );

    Date of the last modification of the post:

    function ben_ntb_funct_filter_title( $string, $ntb ) {
    	// filter title news-ticker-benaceur https://benaceur-php.com/?p=1747
        $d = date_i18n( 'd/m/Y', strtotime( $ntb[2] ) );
    
        return '[ modified: '.$d.' ] '.$string;
    }
    add_filter( 'ntb_title_filter_ben', 'ben_ntb_funct_filter_title', 10, 3 );
    • This reply was modified 7 years, 5 months ago by Benaceur.
    • This reply was modified 7 years, 5 months ago by Benaceur.
    • This reply was modified 7 years, 5 months ago by Benaceur.
    Thread Starter quaglia37

    (@quaglia37)

    I’ll try
    Thank you

    Thread Starter quaglia37

    (@quaglia37)

    Great work, it works fine

    Thread Starter quaglia37

    (@quaglia37)

    You can see it here
    https://www.usolimpic.it/

    Thread Starter quaglia37

    (@quaglia37)

    It would be interesting to insert the continuous roll animation, separating posts with a line and keeping the link
    Thanks for your help

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Insert the date’ is closed to new replies.