• Resolved WP Native

    (@nazreenexe)


    I have a custom taxonomy that is assigned to a post type (Product). I couldn’t able to find the meta values in the rest api responses when i fetch them. Please refer to the screenshot in the link. is there anything else i have to do in order to show then in the rest api responses? Please help!

    https://prnt.sc/20qwuva

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter WP Native

    (@nazreenexe)

    Here’s the code for reference

    function cptui_register_my_taxes() {
    
    	/**
    	 * Taxonomy: Country of origins.
    	 */
    
    	$labels = [
    		"name" => __( "Country of origins", "martfury" ),
    		"singular_name" => __( "Country of origin", "martfury" ),
    	];
    
    	
    	$args = [
    		"label" => __( "Country of origins", "martfury" ),
    		"labels" => $labels,
    		"public" => true,
    		"publicly_queryable" => true,
    		"hierarchical" => true,
    		"show_ui" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"query_var" => true,
    		"rewrite" => [ 'slug' => 'country_of_origin', 'with_front' => true, ],
    		"show_admin_column" => true,
    		"show_in_rest" => true,
    		"show_tagcloud" => true,
    		"rest_base" => "Country",
    		"rest_controller_class" => "WP_REST_Terms_Controller",
    		"show_in_quick_edit" => true,
    		"show_in_graphql" => false,
    		"meta_box_cb" => "country_of_origin",
    	];
    	register_taxonomy( "country_of_origin", [ "product" ], $args );
    }
    add_action( 'init', 'cptui_register_my_taxes' );
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The two parts that stand out the most, and are things that cause some extra consideration from the user are the custom-set “rest base” as well as that “meta_box_cb” value.

    Is the rest base value and the meta box callback values being explicitly used by you? or did they just feel like they needed to be filled in?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Taxonomy doesn’t show in rest api’ is closed to new replies.