小编Jua*_* R.的帖子

如何使用Radicale同步Google日历?

我有自己的日历与Radicale服务器一起使用,我想将我的日历与我的谷歌日历同步,如果我在我的日历中创建一个事件我想在我的谷歌日历中看到它,如果我在谷歌日历中编辑该事件我想要查看我日历中的更改.

我知道使用谷歌日历api我可以从我的日历设置事件,但不能从谷歌到我的日历.

我正在使用此客户端连接radicale:https://github.com/gaye/dav

有办法做到这一点?

icalendar calendar google-calendar-api radicale

7
推荐指数
0
解决办法
902
查看次数

如何对wp_query的结果进行排序

我正在尝试对wp_query的结果进行排序,我希望通过不同的参数对其进行排序,而无需再次进行查询.我有类似的东西:

$the_query = new WP_Query( $args );
Run Code Online (Sandbox Code Playgroud)

我想要排序$ the_query,WP_Query返回一个这样的结构:

$the_query->posts[0]->title; 
Run Code Online (Sandbox Code Playgroud)

所以,我想用'title'对所有元素进行排序.我试过这个:

usort($the_query->posts, function($a, $b) {
   return $a['title'] - $b['title'];
});
Run Code Online (Sandbox Code Playgroud)

我想在查询之后进行排序.是因为我想要多次tosort,我不想每次我想要排序时进行查询

这将返回致命错误:无法使用WP_Post类型的对象作为数组

usort($the_query->posts, function($a, $b) {
   return $a['title'] - $b['title'];
});
Run Code Online (Sandbox Code Playgroud)

这是因为数组的结构是这样的:

$the_query->posts[0]->title; 
Run Code Online (Sandbox Code Playgroud)

所以你必须要改变$a['title'] - $b['title']$a->title - $b->title ,用彼得·古森的答案最后的结果是:

usort($the_query->posts, function($a, $b) {
    return strcasecmp( 
            $a->title, 
            $b->title
        );
});
Run Code Online (Sandbox Code Playgroud)

谢谢大家

php arrays sorting wordpress wp-query

4
推荐指数
1
解决办法
6846
查看次数