Forums

new taxonomy on Page AND Post doesn't show in both (2 posts)

  1. mouais666
    Member
    Posted 1 year ago #

    Hi all,
    i am registering a new taxonomy let's call it "newtax" on post AND page like that

    $siteLabels = array(
        'name' => _x( 'newtax', 'newtax' ),
        'singular_name' => _x( 'newtax', 'newtax' ),
        'search_items' =>  __( 'Search newtaxs' ),
        'all_items' => __( 'All newtaxs' ),
        'parent_item' => __( 'Parent newtax' ),
        'parent_item_colon' => __( 'Parent newtax:' ),
        'edit_item' => __( 'Edit newtax' ),
        'update_item' => __( 'Update newtax' ),
        'add_new_item' => __( 'Add New newtax' ),
        'new_item_name' => __( 'New newtax Name' ),
        'menu_name' => __( 'newtax' ),
    	);
    
    	register_taxonomy('newtax', 'post',  array(
    	'label' => 'newtax',
    	'labels' => $siteLabels,
    	'hierarchical' => true,
    	'query_var' => true,
    	'show_ui' => true,
    	'rewrite' => true ) );
    
    	register_taxonomy('newtax', 'page',  array(
    	'label' => 'newtax',
    	'labels' => $siteLabels,
    	'hierarchical' => true,
    	'query_var' => true,
    	'show_ui' => true,
    	'rewrite' => true ) );

    but the taxonomy is only shown in page or post (depending of the order of the taxonomy registration)

    any idea ?

  2. mouais666
    Member
    Posted 1 year ago #

    mmm I answer to myself

    use register_taxonomy_for_object_type to add an existing taxonomy... otherwise it overwrites the current taxonomy
    :)

Topic Closed

This topic has been closed to new replies.

About this Topic