• Hi!

    Thank you for this awesome plugin. It has great features. I was serching for a way to abbreviate the views above 1000 to see them like 1k (1000+ views), 2k, etc and avoid layout issues.

    https://ibb.co/rb9q8g

    Could you provide any filter or option to do it?

    Thank you a lot,

    álex

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter alexg9

    (@alexg9)

    Hi?

    Plugin Author dFactory

    (@dfactory)

    Hi,

    The views number is handled by the number_format_i18n function which has a filter of exactly the same name. Just try using that and it should do the trick.

    Thread Starter alexg9

    (@alexg9)

    I’ve tried this code but it didn’t work:

    function abbreviation_views($views) {

        if($views >= 1000) {

            $views = number_format_i18n($views/1000, 1) . ‘k’;

        }

        return $views;

    }

    add_filter(‘number_format_i18n’, ‘abbreviation_views’);

    Thread Starter alexg9

    (@alexg9)

    Anybody there?

    Thread Starter alexg9

    (@alexg9)

    Hello?

    Plugin Author dFactory

    (@dfactory)

    I’m sorry, but we don’t provide development support.

    But you can’t use the number_format_i18n function in a filter of that function – it would be an infinite loop. Just do something with this part like:

    $views = (int) ($views/1000) . ‘k’;

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to abbreviate the views?’ is closed to new replies.