artemsemkin

Rhye WordPress Theme: Enable hierarchical categories

Apr 19th, 2021 (edited)
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. add_filter( 'register_post_type_args', 'custom_cpt_enable_categories_hierarchy', 10, 2 );
  4. function custom_cpt_enable_categories_hierarchy( $args, $post_type ) {
  5.  
  6.   if ( $post_type === 'arts_portfolio_item' ) {
  7.     $args['hierarchical'] = true;
  8.   }
  9.  
  10.   return $args;
  11. }
  12.  
  13. add_filter( 'register_taxonomy_args', 'custom_taxonomy_enable_categories_hierarchy', 10, 3 );
  14. function custom_taxonomy_enable_categories_hierarchy( $args, $taxonomy, $object_type ) {
  15.  
  16.   if ( $taxonomy === 'arts_portfolio_category' ) {
  17.     $args['hierarchical'] = true;
  18.   }
  19.  
  20.   return $args;
  21. }
Add Comment
Please, Sign In to add comment