Skip to content

Instantly share code, notes, and snippets.

@tomdevisser
Last active February 9, 2025 22:04
Show Gist options
  • Save tomdevisser/5b6f8959346dd0f62400c2d7bc3fdcc2 to your computer and use it in GitHub Desktop.
Save tomdevisser/5b6f8959346dd0f62400c2d7bc3fdcc2 to your computer and use it in GitHub Desktop.
<?php
/**
* Displays a custom taxonomy meta box without adder.
*
* @param WP_Post $post Current post object.
* @param array $box Categories meta box arguments.
* @return void
*/
function toms_custom_meta_box_without_adder( WP_Post $post, array $box ): void {
$tax_name = esc_attr( $box['args']['taxonomy'] );
?>
<div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv toms-custom-meta-box">
<?php echo "<input type='hidden' name='tax_input[' . $tax_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 ) ); ?>
</ul>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment