0
게시물에 일치하는 용어가있는 경우 카테고리에 게시물을 할당하는 간단한 함수가 있습니다 (save_post 사용). 문제는 하나의 용어로 작동하지만 여러 용어를 일치시키려는 것이 효과가 없다는 것입니다. 이 작품 : WordPress의 모든 태그와 일치
function categorize_from_tags($post_id) {
$cat_boosted = 'cat-boosted';
$terms = 'twin-turbo';
if(has_term($terms, 'post_tag')) {
wp_set_object_terms($post_id, $cat_boosted, 'category', true);
}
}
add_action('save_post', 'categorize_from_tags', 120, 1);
내가 여러 조건을 추가
, 그것은 작동하지 않습니다 당신은 ', UGR 트윈 터보'의 범주 이름에 보내는function categorize_from_tags($post_id) {
$cat_boosted = 'cat-boosted';
$terms = 'twin-turbo,ugr'; // Adding more than one term
if(has_term($terms, 'post_tag')) {
wp_set_object_terms($post_id, $cat_boosted, 'category', true);
}
}
add_action('save_post', 'categorize_from_tags', 120, 1);
감사! 완벽하게 작동합니다. –