Forums

[closed] WP warnings for custom taxonomies (5 posts)

  1. kilobytes
    Member
    Posted 5 months ago #

    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?

  2. Andrew Nacin
    WordPress Dev
    Posted 5 months ago #

    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.

  3. kilobytes
    Member
    Posted 5 months ago #

    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

  4. kilobytes
    Member
    Posted 5 months ago #

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

    it's related to http://wordpress.org/support/topic/plugin-google-xml-sitemaps-error-in-sql-query-for-custom-taxonomies

  5. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 5 months ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic