WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get_terms invalid taxonomy (3 posts)

  1. Topher
    Member
    Posted 2 years ago #

    In my theme functions.php I have this code:

    $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) );

    and it works great.

    I have the same code in a plugin and it says this:

    object(WP_Error)#1096 (2) {
      ["errors"]=>
      array(1) {
        ["invalid_taxonomy"]=>
        array(1) {
          [0]=>
          string(16) "Invalid taxonomy"
        }
      }
      ["error_data"]=>
      array(0) {
      }
    }

    Why would context matter? And what can I do about it?

  2. Topher
    Member
    Posted 2 years ago #

    I figured it out. My test was simply calling my function in the plugin, which was too early in the init. Hooking my function to init made it fire later, and showed me that it was indeed getting the right data.

  3. Dinesh Kesarwani
    Member
    Posted 2 years ago #

    @Toper
    I am getting the same error...

    WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data] => Array ( ) )

Topic Closed

This topic has been closed to new replies.

About this Topic