On the Blogpost I have categories showing, is there a way to exclude a catgegory like ‘Media’?

Add this simple check to your foreach loop: <?php $categories = get_the_category(); foreach($categories as $cat): if ( $cat->name == ‘Media’ ) continue; ?> <a href=”<?php echo get_category_link($cat->term_id); ?>”> <?php echo $cat->name; ?> </a> <?php endforeach; ?> You can check the category name against the list of categories: <?php $categories = get_the_category(); foreach($categories as $cat): if … Read more

How to display a value inside a post with a specified category from a category custom field? [closed]

You can use get_the_category() to get the categories assigned to a specific post and use the_field() or get_field() to display/get the value of a specific ACF field. (You can also use get_term_meta() in place of get_field()) So for example, the following will display a simple list of the categories (and I really mean plain simple), … Read more

How to list all categories and their IDs using SQL query?

I finally got the solution. Below SQL Query gets the list of all categories with it’s ID from WordPress table – SELECT wp_term_taxonomy.term_id, wp_terms.name FROM wp_term_relationships LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) LEFT JOIN wp_terms ON (wp_terms.term_id = wp_term_taxonomy.term_taxonomy_id) WHERE wp_term_taxonomy.taxonomy = ‘category’ GROUP BY wp_term_taxonomy.term_id order by wp_terms.name Hope this could help others.