Выборка WP_Query

92 views
Skip to first unread message

Cyrill KALITA

unread,
Aug 3, 2012, 10:12:12 AM8/3/12
to ru-wor...@googlegroups.com
На странице single-custom_post_type.php внутри цикла вывода я хочу вывести дополнительную информацию - из другой таксономии.

$xargs = array(
'category' => 71,
'post_type' => 'ioni_task',
'numberposts' => 3
);

$the_query = new WP_Query($xargs);

А выдает мне вообще все сообщения типа "ioni_task". 

Поэтому я попробовал print_r($the_query) - и как такое вообще возможно? 
...
[query] => Array
(
[category] => 71
    [post_type] => ioni_task
    [numberposts] => 3
   )
[request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'ioni_task' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')  ORDER BY wp_posts.post_date DESC LIMIT 0, 10

Почему WP_Query может не обновлять request?


Cyrill KALITA

unread,
Aug 3, 2012, 10:20:46 AM8/3/12
to ru-wor...@googlegroups.com
Ответ - брат опыта, они оба сыновья ошибок трудных.
Список категорий для выборки передавать не в списком в category, а в массиве category__in

$xargs = array(
'category__in' => array(71),
'post_type' => 'ioni_task',
'numberposts' => 3
);

 

Roman Kokarev

unread,
Aug 3, 2012, 10:25:32 AM8/3/12
to ru-wor...@googlegroups.com
Семён Семёныч... :-)

3 августа 2012 г., 20:20 пользователь Cyrill KALITA
<cyrill...@gmail.com> написал:

> --
> http://groups.google.com/group/ru-wordpress

--
Цените своё Время.
С уважением,
Roman Kokarev.

Reply all
Reply to author
Forward
0 new messages