yaoruisheng 大佬有话说 : 2019-12-15 21:37:25
修改wordpress的widget,逻辑混乱了。总觉得可以优化。。。
本帖最后由 yaoruisheng 于 2019-12-15 21:39 编辑
global $wp_query;
$args = $instance[‘show_pagination’]?$wp_query->query_vars:array();
if ($instance[‘show_pagination’] || false === ( $wp_query = get_transient( ‘simpletext_recent_widget_’ . $this->id ) ) ) {
// Posts query arguments.
$args = array_replace($args ,array(
‘post_type’ => ‘post’,
‘posts_per_page’ => $instance[‘limit’]
));
// The post query
$wp_query = new WP_Query( $args );
// Store the transient.
if ( !$instance[‘show_pagination’] ) set_transient( ‘simpletext_recent_widget_’ . $this->id, $wp_query );
}
rooney 大佬有话说 : 2019-12-15 21:41:24
这啥呀,怎么这么啰嗦
yaoruisheng 大佬有话说 : 2019-12-15 22:12:35
rooney 大佬有话说 : 2019-12-15 21:41
这啥呀,怎么这么啰嗦
对啊,我看着就是啰嗦,但是被圈住了,看不出。