-2

Could you explain to me how add filter date : "1 week ago"

Thanks for your help

/* Variables from the widget settings. */

        $title = apply_filters('widget_title', $instance['title'] );

        $number = $instance['number'];

        $checkbox = $instance['checkbox'];

        $top_popular_posts = new WP_Query('showposts=' . $number . '&orderby=rand&order=DESC');


        if ($top_popular_posts->have_posts()) :



        echo $before_widget;
1
  • Is this code you can edit, or do you need to filter the results from a separate theme/plugin? Commented Aug 20, 2017 at 10:51

1 Answer 1

-1

You can do this in WordPress via:

 <?php human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>

Refernece: https://codex.wordpress.org/Function_Reference/human_time_diff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.