Support » Developing with WordPress » Get Taxonomy name from “registered_taxonomy” hook

  • I am using add_action to run a function after a taxonomy is created. Everything works but I can’t figure out how to grab the taxonomy name. I figured $args->name would be the way to go but it is not working, it is not returning anything.

    function test( $taxonomy, $object_type, $args ) {
    $catname = $args->name;
    }

    add_action( ‘registered_taxonomy’, ‘test’,10, 3 );

Viewing 1 replies (of 1 total)
  • Aboelabbas

    (@dawn-birth)

    Taxonomy name is a property of labels object; It should be like this:
    $catname = $args['labels']->name;

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.