WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. zuzuleinen
    Member
    Posted 2 years 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. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 2 years ago #

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

  3. zuzuleinen
    Member
    Posted 2 years ago #

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

  4. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 2 years ago #

    lol, thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic