Forums

Yet Another Related Posts Plugin
Undefined offset 0 for Custom Posts with no category (4 posts)

  1. zuzuleinen
    Member
    Posted 5 months ago #

    If I select no category for my Custom post type (but for WP still remains "Uncategorized"), I get
    Notice: Undefined offset: 0 in ...\wp-content\plugins\breadcrumbs\yoast-breadcrumbs.php on line 230

    $cats = get_the_category();
    $cat = $cats[0]; // line 230

    The problem is that WP's get_the_category() has this at the beginning:

    $categories = get_the_terms( $id, 'category' );
    if ( ! $categories )
    	$categories = array();
    
    // ... more stuff below

    The rest of the code doesn't modify the array (not the function per se), so it's bound to return empty if no categs are found. Thus the undefined offset 0.

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. Wait... is this an issue with YARPP? I don't think you're describing a YARPP issue...

  3. zuzuleinen
    Member
    Posted 5 months ago #

    Damn it. Sorry. It's not. I was confused by all the Y* plugins. Closing.

  4. lol, thanks.

Reply

You must log in to post.

About this Plugin

About this Topic