-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;
  • Is this code you can edit, or do you need to filter the results from a separate theme/plugin? – Jacob Peattie Aug 20 '17 at 10:51
-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, privacy policy and cookie policy

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