WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#13373 closed defect (bug) (invalid)

category function creates error: Object of class WP_Error could not be converted to string

Reported by: christian_gnoth Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9.2
Component: General Keywords: get_cat_id, get_category_link, WP_error
Focuses: Cc:

Description (last modified by nacin)

Hello,

I am using the following PHP script lines:

 $category_id = get_cat_ID( $row['title'] );
 // Get the URL of this category
 $category_link = get_category_link( $category_id );
 $j2wp_post['post_content'] =  substr( $j2wp_post['post_content'], 0, $lnk_pos) . 'href="' . $category_link . '" ' . substr( $j2wp_post['post_content'], $post_lnk_end + 1);

they create the subsequent error in the assignment:

$j2wp_post['post_content'] =

Catchable fatal error: Object of class WP_Error could not be converted to string 

As there is no error in the assignment and I found a lot of hints for the categories - one of this two fundtions creates this error.

Change History (4)

comment:1 @nacin5 years ago

  • Description modified (diff)

comment:2 @nacin5 years ago

  • Milestone Unassigned deleted
  • Priority changed from high to normal
  • Resolution set to worksforme
  • Severity changed from major to normal
  • Status changed from new to closed

One of the values you are using there is a WP_Error object, and not what you expect.

My guess is it is get_category_link().

comment:3 @nacin5 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

comment:4 @nacin5 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.