Support » Plugin: news ticker benaceur » Insert the date
Insert the date
-
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 newsThank you
-
If I understand correctly, you want to add the date of post before or after the title? If so, which animation is selected
I want to add the date before the title, scroll left animation
Thank youfirst: 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 http://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.wordpress.org/Formatting_Date_and_Time
example:
change this ‘d/m/Y’ to ‘d M Y H-i’and this without style:
function ben_ntb_funct_filter_title( $string, $ntb ) { // filter title news-ticker-benaceur http://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 http://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 http://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 http://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 );
I’ll try
Thank youGreat work, it works fine
You can see it here
http://www.usolimpic.it/It would be interesting to insert the continuous roll animation, separating posts with a line and keeping the link
Thanks for your help
- The topic ‘Insert the date’ is closed to new replies.