wp_terms_checklist example

</ul> </div> <div id="<?php echo $tax_name; ?>-all" class="tabs-panel"> <?php             $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
            // Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.             echo "<input type='hidden' name='{$name}[]' value='0' />";
            ?> <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear"> <?php                 wp_terms_checklist(
                    $post->ID,
                    array(
                        'taxonomy'     => $tax_name,
                        'popular_cats' => $popular_ids,
                    )
                );
                ?> </ul> </div> <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> <div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children"> <a id="
$cat_id = $cat_id['term_id'];
        }

        $checked_categories[] = $cat_id;

        if ( $parent ) { // Do these all at once in a second.             continue;
        }

        ob_start();

        wp_terms_checklist(
            0,
            array(
                'taxonomy'             => $taxonomy->name,
                'descendants_and_self' => $cat_id,
                'selected_cats'        => $checked_categories,
                'popular_cats'         => $popular_ids,
            )
        );

        $data = ob_get_clean();

        

function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
    wp_terms_checklist(
        $post_id,
        array(
            'taxonomy'             => 'category',
            'descendants_and_self' => $descendants_and_self,
            'selected_cats'        => $selected_cats,
            'popular_cats'         => $popular_cats,
            'walker'               => $walker,
            'checked_ontop'        => $checked_ontop,
        )
    );
}

<?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> <fieldset class="inline-edit-col-center inline-edit-categories"> <div class="inline-edit-col"> <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> <input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> <?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> </ul> <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> </div> </fieldset> <?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?> <fieldset class="inline-edit-col-right"> <div class="inline-edit-col">
Home | Imprint | This part of the site doesn't use cookies.