문제

I have the following code that prints a comma separated list which I need in the form of an array, how do I get the list of id's into an array called $excluded_categories with contents as per below?

$categories = get_categories(array('taxonomy'=>'projects_category', 'exclude'=>7, 'orderby'=>'id'));
if ( !empty( $categories ) ) :
foreach($categories as $term){
    echo $term->term_id.', '; // prints: 1,2,3,4,5,6,8,9,
    }
endif;

$excluded_categories would be an array containing: 1,2,3,4,5,6,8,9

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top