Add variable : 1 Week ago

时间:2017-08-20 作者:Skysool

你能给我解释一下如何添加筛选日期:“1周前”

谢谢你的帮助

/* 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 个回复
SO网友:Shahzaib Khan

您可以通过以下方式在WordPress中执行此操作:

 <?php human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . \' ago\'; ?>
参考文献:https://codex.wordpress.org/Function_Reference/human_time_diff

结束

相关推荐

如何像在CodeIgniter中一样打印WP_QUERY类中的原始查询

我正在与WordPress进行斗争WP_Query. 我们通常传递一个参数数组来获取结果。$args = array( \'post_type\' => \'post\', \'post_per_page\' => \'2\', \'orderby\' => \'meta_value_num\', \'order\' => \'DESC\', \'ignore_s