1
실제로 pre_get_post에서이 같은 후크를 갖고 싶어 :이나는 설정 "post_type 또는 tax_query"
add_action('pre_get_posts', 'my_post_pre_get_posts');
function my_post_pre_get_posts($query)
{
if (!is_admin() && $query->is_main_query() && $query->is_home()) {
$query->set('posts_per_page', 3);
//FILTERS
$type = array();
if(!empty($_GET['type'])) {
$type = explode(',', $_GET['type']);
}else {
$type = array('post', 'testimonial', 'project');
}
$query->set('post_type', $type);
//CATEGORIES
if(!empty($_GET['category'])) {
$category = explode(',', $_GET['category']);
$args = array(
'relation' => 'OR',
);
foreach ($category as $categorie) {
array_push($args,
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => $category
)
);
}
$query->set('tax_query', $args);
}
}
}
, 내 집 디스플레이 게시물 또한 두 개의 다른 사용자 정의 포스트 유형 : " 프로젝트 "와"증언 ".
내 게시물 (그러나 프로젝트 및 회원 평가가없는)이 있고 그것으로 그것들을 걸러 내고 싶습니다. 그러나 분류법으로 필터링 할 때 프로젝트 및 고객 평가 결과가 숨겨지는 것을 원하지 않습니다.
post_type과 택 소노 미 사이에 "AND"관계가있는 대신 "OR"관계가 필요합니다.. 가능하다고 생각하십니까? 글로벌 $ wpdb를 다시 작성해야합니까? 당신의 'tax_query'와 함께 당신의 카테고리 루프 후