The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress: how to display taxonomy metaboxes only on certain pages?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #148237

    I have a section of a website called The Team. I’ve written some code so that taxonomy metaboxes show up in the admin sidebar of Pages and the client can specify team members.

    But I only want those metaboxes to display when my custom page template (“Team”) has been selected. Is this possible? Here is the code so far:

    add_action( 'init', 'register_taxonomy_team_members' );
    function register_taxonomy_team_members() {
    $labels = array(
        'name' => _x( 'Team Members', 'team_members' ),
        'singular_name' => _x( 'Team Member', 'team_members' ),
        'search_items' => _x( 'Search Team Members', 'team_members' ),
        'popular_items' => _x( 'Popular Team Members', 'team_members' ),
        'all_items' => _x( 'All Team Members', 'team_members' ),
        'parent_item' => _x( 'Parent Team Member', 'team_members' ),
        'parent_item_colon' => _x( 'Parent Team Member:', 'team_members' ),
        'edit_item' => _x( 'Edit Team Member', 'team_members' ),
        'update_item' => _x( 'Update Team Member', 'team_members' ),
        'add_new_item' => _x( 'Add New Team Member', 'team_members' ),
        'new_item_name' => _x( 'New Team Member', 'team_members' ),
        'separate_items_with_commas' => _x( 'Separate team members with commas', 'team_members' ),
        'add_or_remove_items' => _x( 'Add or remove Team Members', 'team_members' ),
        'choose_from_most_used' => _x( 'Choose from most used Team Members', 'team_members' ),
        'menu_name' => _x( 'Team Members', 'team_members' ),
    $args = array(
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => false,
        'show_ui' => true,
        'show_tagcloud' => false,
        'show_admin_column' => true,
        'hierarchical' => false,
        'rewrite' => true,
        'query_var' => true
    register_taxonomy( 'team_members', array('page'), $args );

    Not sure if this is directly possible. It would be if you had a custom post type and you’d want the taxonomy option only to show on a page where you create or edit a post of that custom type.

    In that case, it would be something like this:

    register_taxonomy('team_members',array (0 => 'products'), $args);
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.