下面是我写给 WP_Query 一堆过滤器的代码,这些过滤器涉及帖子的自定义元字段,
<?php
global $post;
$month=date("m", time()); //current month
$month=intval($month); //converting '03' to int 3
$args = array( 'meta_key'=>"city", 'meta_value'=>'NY', 'numberposts' => 100,
'cat'=>"read", "monthnum" => $month, 'post_status' => "publish",
'order'=>"ASC", "orderby" => "meta_value_num", "meta_key" => "article_order");
$posts = WP_Query( $args );
?>
我想从上面的查询中实现的是,“从 'read' 类别中选择本月发布的帖子,元键 'city' 的值为 'NY' 并按 meta_key 'article_order' 的 'meta_value_num' 排序”