unclebobby
Forum Replies Created
-
To make it clear here is a screenshot of what I want to do
- This reply was modified 4 years, 5 months ago by unclebobby.
- This reply was modified 4 years, 5 months ago by unclebobby.
This displays popular posts. But I need to display the number of views in a post for all time, for a month and for a day
Oh yeah! Yes! Thank! ??
And again. Numbers are reduced from 33 000 to 33, But without the letter “k”.
But, if I change the number 0 in the second line to 3 or more, the letter “k” is added. And then all the numbers and hundreds and millions will be with the letter “k”For example code:
function tptn_restyle_count( $input ) { $input = number_format( intval( $input ), 3, ',', '.' ); $input_count = substr_count( $input, ',' ); if ( $input_count != '0' ) { if ( $input_count == '1' ) { return substr( $input, 0, -4 ) . 'k'; } elseif ( $input_count == '2' ) { return substr( $input, 0, -8 ) . 'm'; } elseif ( $input_count == '3' ) { return substr( $input, 0, -12 ) . 'bn'; } else { return; } } else { return $input; } } add_filter( 'tptn_post_count_only', 'tptn_restyle_count' );
Out of 541 -> number 541,0k
33 354 -> 33,0kMaybe this will help find the right solution.
Does not work again.
If I use code from this link https://gist.github.com/ajaydsouza/d0ddf2461cebab09cc38eb5ea0697cae
The code does not work at all, space or comma doesn’t change anything. The numbers do not change.If I use this code:
function tptn_restyle_count( $input ) { $input = number_format($input); $input_count = substr_count( $input, ',' ); if ( $input_count != '0' ) { if ( $input_count == '1' ) { return substr( $input, 0, -4 ) . 'k'; } elseif ( $input_count == '2' ) { return substr( $input, 0, -8 ) . 'm'; } elseif ( $input_count == '3' ) { return substr( $input, 0, -12 ) . 'bn'; } else { return; } } else { return $input; } } add_filter( 'tptn_post_count_only', 'tptn_restyle_count' );
Numbers are reduced from 32 000 to 32, But without the letter “k”, and again, space or comma doesn’t change anything
for example this page https://onibi.ru/manga/fox-girls-are-better/
tptn_counter is on the right, near the eye icon.It did not work. The number has not changed. How was 31000 and 31000 left
I added a filter at the end of the file counter.php
add_filter( 'tptn_post_count_only' , 'restyle_text' );
and added a function in the file function.php
function restyle_text($input){ $input = number_format($input); $input_count = substr_count($input, ','); if($input_count != '0'){ if($input_count == '1'){ return substr($input, 0, -4).'k'; } else if($input_count == '2'){ return substr($input, 0, -8).'mil'; } else if($input_count == '3'){ return substr($input, 0, -12).'bil'; } else { return; } } else { return $input; } }
And the numbers began to decline, but the letter is not added. That is, the number 29993 has changed just to 29 without the “k”.
I do not understand why. Try this code and tell me if you succeed