Fatal error: Cannot use object of type WP_Error as array.. Help!

  • Unknown's avatar

    Hi All,

    I’m trying to figure out why within the past week, I started getting this error while importing products from Amazon via their API. The plugin is called Compare Plus. At the end of the import, it shows:

    Fatal error: Cannot use object of type WP_Error as array in /home/caraudj2/public_html/wp-content/plugins/compare-plus/compare_cron.php on line 1274

    Line 1274 is:
    wp_set_post_terms($id, intval($term[‘term_id’]), ‘product_category’,true);

    Here’s the 1260 – 1277 (if it helps)
    wp_delete_object_term_relationships( $id, array(‘product_category’) );
    if(is_numeric($category)) {
    $term = get_term_by(‘id’,$category,’product_category’);
    } else {
    //When searching for the term remove al sets of spaces greater than 1, it seems when the term is added to the database these are stripped out by wordpress
    $term = get_term_by(‘name’,preg_replace(‘/ {2,}/’, ‘ ‘, stripslashes($category)),’product_category’);
    if(!$term) {
    //When searching for the term remove al sets of spaces greater than 1, it seems when the term is added to the database these are stripped out by wordpress
    $term = get_term_by(‘name’,preg_replace(‘/ {2,}/’, ‘ ‘, htmlspecialchars(stripslashes($category))),’product_category’);
    }
    }

    if(!$term) {
    $term = wp_insert_term(htmlspecialchars(stripslashes($category)),’product_category’);
    wp_set_post_terms($id, intval($term[‘term_id’]), ‘product_category’,true);
    } else {
    wp_set_post_terms($id, intval($term->term_id), ‘product_category’,true);
    }

    Haven’t been able to find anything that’s specific to my case. Could use some help!

    Greatly appreciated

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Hi kameronscott

    Although you are referring to your WordPress.com blog – kameronscott.wordpress.com, it seems like your question is related to a self hosted WordPress.org installation.

    This support forum is for sites that are hosted with WordPress.com

    For self-hosted WordPress sites like yours, you can get help in the WordPress.org support forums – http://WordPress.org/support/

    WordPress comes in two flavours. WordPress.com and WordPress.org

    This article does a good job of explaining the differences –http://en.support.wordpress.com/com-vs-org/

  • The topic ‘Fatal error: Cannot use object of type WP_Error as array.. Help!’ is closed to new replies.