Support » Alpha/Beta/RC » WP warnings for custom taxonomies

  • WP is throwing some warnings in get_term_link() because it’s not finding the expected object attribute. The plugin code causing this is right after the sql query that fetches custom taxonomies:

    get_term_link($term, $term->_taxonomy)

    WP however expects get_term_link($term, $term->taxonomy), which means that inside get_term_link the code doesn’t branch out as intended and returns an incomplete link.

    Just wondering if this is intentional or a bug?

Viewing 4 replies - 1 through 4 (of 4 total)
  • get_term_link($term, $term->_taxonomy)

    Could we have some example code and the warning returned?

    get_term_link() will work as long as $term is a complete term object, and it will ignore anything passed in for the second $taxonomy parameter. That means even if $term->_taxonomy returns '', it should still work.

    Actually, they are PHP Notices, not Warnings:

    PHP Notice: Trying to get property of non-object in /wp-includes/taxonomy.php on line 2891

    $taxonomy = $term->taxonomy; // line 2891

    PHP Notice: Undefined property: stdClass::$taxonomy in /wp-includes/taxonomy.php on line 2901

    elseif ( $t->query_var ) // line 2901

    The $term object doesn’t contain the expected property, because the alias in the plugin’s sql query is “_taxonomy”:

    SELECT ... tt.taxonomy AS _taxonomy (sitemap-core.php line 2126)

    Then inside get_term_link() the code branches to line 2904 and produces an incomplete link because $taxonomy is empty

    $termlink = "?taxonomy=$taxonomy&term=$slug"; // line 2904

    oops…this should probably be in Plugin: Google XML Sitemaps

    it’s related to

    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Plugin Review Team Rep

    Right… So this is happening on WordPress 3.2? I’m closing this post. Take it up in your other post.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP warnings for custom taxonomies’ is closed to new replies.