• Resolved r083r7

    (@r083r7)


    I added this code to my functions.php file to add custom categories to the native WP Pages. But they are not showing up when I go to edit the page. I expected that on the right sidebar it would be one of the widgets but it’s not there. Am I missing anything here?

    
    function pagecategory_taxonomy()
    {
    
        $labels = array(
            'name'                       => _x('Page Categories', 'Taxonomy General Name', 'text_domain'),
            'singular_name'              => _x('Page Category', 'Taxonomy Singular Name', 'text_domain'),
            'menu_name'                  => __('Categories', 'text_domain'),
            'all_items'                  => __('All Categories', 'text_domain'),
            'parent_item'                => __('Parent Category', 'text_domain'),
            'parent_item_colon'          => __('Parent Category:', 'text_domain'),
            'new_item_name'              => __('New Category Name', 'text_domain'),
            'add_new_item'               => __('Add New Category', 'text_domain'),
            'edit_item'                  => __('Edit Category', 'text_domain'),
            'update_item'                => __('Update Category', 'text_domain'),
            'view_item'                  => __('View Item', 'text_domain'),
            'separate_items_with_commas' => __('Separate page categories with commas', 'text_domain'),
            'add_or_remove_items'        => __('Add or remove page categories', 'text_domain'),
            'choose_from_most_used'      => __('Choose from the most used page categories', 'text_domain'),
            'popular_items'              => __('Popular Items', 'text_domain'),
            'search_items'               => __('Search page categories', 'text_domain'),
            'not_found'                  => __('Not Found', 'text_domain'),
            'no_terms'                   => __('No items', 'text_domain'),
            'items_list'                 => __('Items list', 'text_domain'),
            'items_list_navigation'      => __('Items list navigation', 'text_domain'),
        );
        $args = array(
            'labels'                     => $labels,
            'hierarchical'               => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => false,
        );
        register_taxonomy('page_category', array('page'), $args);
    }
    add_action('init', 'pagecategory_taxonomy', 0);
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Using the block editor, right? It uses the API to get such data, so when you register a new taxonomy you must include 'show_in_rest'=> true, in $args. You got almost every “show” arg in existence but the one you really needed 🙂

    Thread Starter r083r7

    (@r083r7)

    That did it, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom categories not showing up on Page Edit screen :(’ is closed to new replies.