• Hi
    This plugin doesn’t seem to be actively supported any more, so I’ll post a bit of code (that works for me).
    Since the last update, I get a pair of PHP error message under certain circiumstances :

    Undefined offset: 0 in [...]/plugins/extended-categories-widget/4.2/class/avh-ec.core.php on line 140
    Trying to get property of non-object in [...]/extended-categories-widget/4.2/class/avh-ec.core.php on line 140

    These seem to occur when the post is not assigned to a category. WordPress assigns normal post types to the “Uncategorised” category, but custom post types can be unassigned – particularly when saved as drafts.
    The code in question is in the avh-ec.core.php script, at the lines :

    	if (is_single()) {
    			$post_cats                = get_the_category();
    			$args['current_category'] = $post_cats[0]->term_id;
    		}

    Adding a test to check for the existence of a post category resolves this (apparently, the plugin code only assigns a css class, so nothing should be broken).

    	if (is_single()) {
    		$post_cats                = get_the_category();
    		if (!empty( $post_cats ) ) {
    			$args['current_category'] = $post_cats[0]->term_id;
    			}
    		}

    If the author does reissue this (really useful) plugin, then I hope he’ll take this on board.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom post types : “Undefined offset: 0” error’ is closed to new replies.