I want to exclude a specific category from the loop, here's what I tried:
Original code:
// auto posts by cat
if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == 'both' ):
$cat = get_the_category( $post->ID );
$cat_ids = wp_list_pluck( $cat, 'term_id' );
$args['category'] = implode( ',', $cat_ids );
endif;
My try:
// auto posts by cat
if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == 'both' ):
$cat = get_the_category( $post->ID );
if ($cat->cat_ID != '68') :
$cat_ids = wp_list_pluck( $cat, 'term_id' );
endif;
$args['category'] = implode( ',', $cat_ids );
endif;
In my code I tried to exclude the category 68, but actually the best thing would be if the category has children, then it don't enter in the loop, only it's children
$cat
is an array so$cat->cat_ID
will not work. Was there no error encountered in the above code>