Как вывести посты из произвольного типа записи?
Мне нужно вывести произвольные посты вордпресс из определенной таксономии. Как это сделать?
1 Ответ(ы)
Код с рабочего сайта(вовод постов из таксономии):
$portfolio = new WP_Query(array( 'post_type' => 'te_portfolio', 'posts_per_page' => $this->posts_per_page, 'tax_query' => array( array( 'taxonomy' => 'te_category', 'field' => 'id', 'terms' => $this->category_array ) ) )); // query posts if ($portfolio->have_posts()) { while ($portfolio->have_posts()) { $portfolio->the_post(); // add html content portfolio $this->HTML .= $this->preview(get_the_ID() . '-' . $i); $this->HTML .= $this->content(get_the_ID() . '-' . $i); } } wp_reset_query();