nur*_*ain 2 php wordpress loops field
我正在尝试过滤我的帖子,只显示具有"模型"字段的自定义值的帖子,同时按另一个名为"Price"的自定义字段对帖子进行排序.
这是我正在使用的功能(不工作):
<?php
global $query_string;
query_posts( $query_string . "&meta_value=Model&orderby=meta_value&meta_key=Price&order=ASC");
?>
Run Code Online (Sandbox Code Playgroud)
此功能仅显示模型,但不按价格对帖子进行排序.如果我&meta_value=Model在order=ASC按价格排序后添加,但显示所有帖子,而不仅仅是模型.
你看过http://codex.wordpress.org/Class_Reference/WP_Query吗?
具体这一部分:
多个自定义字段处理:
显示多个自定义字段的帖子:
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'color',
'value' => 'blue',
'compare' => 'NOT LIKE'
),
array(
'key' => 'price',
'value' => array( 20, 100 ),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
)
);
$query = new WP_Query( $args );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7705 次 |
| 最近记录: |