Assign post category to a page by selecting category from page dashboard

add this code into functions.php and a taxonomy box will be created for page from where user can make categories for page. <?php add_action( ‘init’, ‘create_book_tax’ ); function create_book_tax() { register_taxonomy( ‘genre’, ‘page’, array( ‘label’ => __( ‘Genre’ ), ‘rewrite’ => array( ‘slug’ => ‘genre’ ), ‘hierarchical’ => true, ) ); } ?>

Getting child category id (help with improving my code)

Starting from your parent category slug you can use the following code to get the child categories: $parent = get_category_by_slug(‘winners-2018’); $catz = get_categories( array( ‘parent’ => $parent->cat_ID ) ); foreach ($catz as $cat_archive) { // No need for get_category(); because get_categories() already returns category objects … }