WordPress.org

Ready to get started?Download WordPress

Forums

Show specific category with child in wp_dropdown_categories (CPT) (1 post)

  1. Marc P Gangmei
    Member
    Posted 3 years ago #

    Here the code: This is a working code
    
    <?php
    global $current_user;
    get_currentuserinfo();
    $authorcategory = get_user_meta( $current_user->ID, 'authorcategory', true );
    $cats_array = get_categories(array('taxonomy' => 'blogs')); ?>
    <select id="cat" name="cat" class="input">
    <?php foreach ( $cats_array as $category ) { ?>
    <?php if ($category->cat_name == $authorcategory) echo $cat->cat_name . ' '; } ?>
    <option value="<?php echo $category->cat_ID; ?>"><?php echo $category->cat_name; ?></option>
    </select>
    
    1. Now how do I show the child cats?
    
    2. How can I hide the parent cat and show only the child cats.

Topic Closed

This topic has been closed to new replies.

About this Topic