WordPress.org

Ready to get started?Download WordPress

Forums

All-in-One Event Calendar
Category Causing Crash on Event Details (5 posts)

  1. markp_2000
    Member
    Posted 2 years ago #

    I'm getting the following. I though it was something else.

    [code]Notice: Undefined offset: 0 in /www/wp-content/themes/shell-lite/includes/functions.php on line 244 Catchable fatal error: Object of class WP_Error could not be converted to string in /www/wp-content/themes/shell-lite/includes/functions.php on line 245
    [/code]

    This is the shell_breadcrumb function. I marked the line with //below is line 244 -

    [code]function shell_breadcrumb_lists() {

    $chevron = '<span>›</span>';
    $name = 'Home'; //text for the 'Home' link
    $currentBefore = '<span class="current">';
    $currentAfter = '</span>';

    echo '<div class="breadcrumb-list">';

    global $post;
    $home = home_url();
    echo '' . $name . ' ';
    if (!is_home())
    echo $chevron . ' ';

    if (is_category()) {
    global $wp_query;
    $cat_obj = $wp_query->get_queried_object();
    $thisCat = $cat_obj->term_id;
    $thisCat = get_category($thisCat);
    $parentCat = get_category($thisCat->parent);
    if ($thisCat->parent != 0)
    echo(get_category_parents($parentCat, TRUE, ' ' . $chevron . ' '));
    echo $currentBefore . 'Archive by category '';
    single_cat_title();
    echo ''' . $currentAfter;
    } elseif (is_day()) {
    echo '' . get_the_time('Y') . ' ' . $chevron . ' ';
    echo '' . get_the_time('F') . ' ' . $chevron . ' ';
    echo $currentBefore . get_the_time('d') . $currentAfter;
    } elseif (is_month()) {
    echo '' . get_the_time('Y') . ' ' . $chevron . ' ';
    echo $currentBefore . get_the_time('F') . $currentAfter;
    } elseif (is_year()) {
    echo $currentBefore . get_the_time('Y') . $currentAfter;
    } elseif (is_single()) {
    $cat = get_the_category();
    //Below is line 244
    $cat = $cat[0];
    echo get_category_parents($cat, TRUE, ' ' . $chevron . ' ');
    echo $currentBefore;
    the_title();
    echo $currentAfter;
    } elseif (is_page() && !$post->post_parent) {
    echo $currentBefore;
    the_title();
    echo $currentAfter;
    } elseif (is_page() && $post->post_parent) {
    $parent_id = $post->post_parent;
    $breadcrumb_lists = array();
    while ($parent_id) {
    $page = get_page($parent_id);
    $breadcrumb_lists[] = 'ID) . '">' . get_the_title($page->ID) . '';
    $parent_id = $page->post_parent;
    }
    $breadcrumb_lists = array_reverse($breadcrumb_lists);
    foreach ($breadcrumb_lists as $crumb)
    echo $crumb . ' ' . $chevron . ' ';
    echo $currentBefore;
    the_title();
    echo $currentAfter;
    } elseif (is_search()) {
    echo $currentBefore . 'Search results for '' . get_search_query() . ''' . $currentAfter;
    } elseif (is_tag()) {
    echo $currentBefore . 'Posts tagged '';
    single_tag_title();
    echo ''' . $currentAfter;
    } elseif (is_author()) {
    global $author;
    $userdata = get_userdata($author);
    echo $currentBefore . 'Articles posted by ' . $userdata->display_name . $currentAfter;
    } elseif (is_404()) {
    echo $currentBefore . 'Error 404' . $currentAfter;
    }

    if (get_query_var('paged')) {
    if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
    echo ' (';
    echo __('Page','shell') . ' ' . get_query_var('paged');
    if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
    echo ')';
    }

    echo '</div>';
    }
    [/code]

    http://wordpress.org/extend/plugins/all-in-one-event-calendar/

  2. markp_2000
    Member
    Posted 2 years ago #

    I commented out the lines in the elseif statement and it now works.

    //$cat = get_the_category();
    //Below is line 244
    //$cat = $cat[0];
    //echo get_category_parents($cat, TRUE, ' ' . $chevron . ' ');
    //echo $currentBefore;
    //the_title();
    //echo $currentAfter;

    Obviously, it is not returning an array from the get_the_category() function call.

  3. markp_2000
    Member
    Posted 2 years ago #

    My work around is to test the variable $cat.

    if( $cat ) {
    		$cat = $cat[0];
    		echo get_category_parents($cat, TRUE, ' ' . $chevron . ' ');
            	echo $currentBefore;
           		the_title();
           		echo $currentAfter;
           	  }
  4. nelra
    Member
    Posted 2 years ago #

    Thanks for the details. A similar report:
    http://wordpress.org/support/topic/all-in-one-event-calendar-catchable-fatal-error

    I'll see if I can recreate this with a test theme and if there is something on our side that can be done to workaround the issue

  5. nospam_please
    Member
    Posted 1 year ago #

    Hi markp_2000,

    Thanks for posting your workaround. I just hit the same bug. I have the Tribe calendar version 2.0.10 with the latest WordPress. The Tribe category bug affects the WPZoom theme (http://www.wpzoom.com/themes/academica/) also.

    Your workaround let me proceed.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic