I have the following code on my site that outputs a list of categories for the 'download' post type. I am looking to exclude certain categories from appearing in the output, how do I do this?
<?php
/**
* Generate list of EDD categories to browse
*/
$args = array(
'orderby' => 'name',
'hierarchical' => 1,
'style' => 'none',
'taxonomy' => 'download_category',
'hide_empty' => 0,
'depth' => 1,
'title_li' => '',
// 'parent' => 0
);
$categories = get_categories( $args );
if ( $categories ) {
?>
<div class="search-cats">
<div class="search-cat-text">
<?php _e( 'Browse by category: ', 'checkout' ); ?>
</div>
<nav>
<?php
/**
* Generate list of EDD category links
*/
foreach ( $categories as $category ) {
$link = get_term_link( $category, 'download_category' );
echo '<a href="' . esc_url( $link ) . '" rel="tag">' . $category->name . '</a>';
}
?>
</nav>
</div>
<?php } ?>
The parameter in your arguments you're looking for is
exclude
see https://developer.wordpress.org/reference/classes/wp_term_query/__construct/ for details on the args available for this type of query.