• Resolved Mihail D

    (@memberremember)


    execute this code

    wp_list_categories('title_li=&show_option_none=false&child_of=' . $category->cat_ID . '&depth=1&number=99&current_category=1');

    but it returned next

    <b>Notice</b>: Trying to get property of non-object in <b>mysite/wp-includes/category-template.php</b> on line <b>1025</b>
    ….
    <b>Notice</b>: Trying to get property of non-object in <b>mysite/wp-includes/category-template.php</b> on line <b>1025</b>

    PS:
    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_DISPLAY’, true);

    easy way to swtch off this values but need fix core error

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Mihail D

    (@memberremember)

    all results returned as i want only (even hidden) notice irritate me

    How is the variable $category created? Can you post the output of var_dump( $category );?

    Thread Starter Mihail D

    (@memberremember)

    source before

    $category = get_category(18); // Industry’s Insights

    var_dump($category);

    object(stdClass)#1740 (16) {
    ["term_id"]=> &int(18)
    ["name"]=> &string(19) "Industry's Insights"
    ["slug"]=> &string(18) "industrys-insights"
    ["term_group"]=> int(0)
    ["term_taxonomy_id"]=> int(18)
    ["taxonomy"]=> string(8) "category"
    ["description"]=> &string(0) ""
    ["parent"]=> &int(0)
    ["count"]=> &int(78)
    ["filter"]=> string(3) "raw"
    ["cat_ID"]=> &int(18)
    ["category_count"]=> &int(78)
    ["category_description"]=> &string(0) ""
    ["cat_name"]=> &string(19) "Industry's Insights"
    ["category_nicename"]=> &string(18) "industrys-insights"
    ["category_parent"]=> &int(0)
    }
    Thread Starter Mihail D

    (@memberremember)

    in <b>mysite/wp-includes/category-template.php</b> on line <b>1025</b>

    if ( !empty($current_category) ) {
    	$_current_category = get_term( $current_category, $category->taxonomy );
    	var_dump($_current_category); // !!!!!!!!
    
    	if ( $category->term_id == $current_category )
    		$class .=  ' current-cat';
    	elseif ( $category->term_id == $_current_category->parent )
    		$class .=  ' current-cat-parent';
    	}

    this dump

    var_dump( $_current_category->parent );
    show NULL

    I’m sorry, but I can’t reproduce your error. When I use your code, I get a list of categories that are child categories of the listed category ID. In your last post, you posted a code snippet from WP core, and my copy doesn’t have the var_dump() line in it. Did you add that yourself? Which line is line 1025?

    Thread Starter Mihail D

    (@memberremember)

    1025 line this:

    elseif ( $category->term_id == $_current_category->parent )

    also i already shown var_dump of $_current_category variable.
    Thats mean – developers couldn’t consider NULL value for $_current_category.

    By another words – current core sources must be like this

    if ( $category->term_id == $current_category )
    	$class .=  ' current-cat';
    elseif ( isset($_current_category->parent) && $category->term_id == $_current_category->parent )
    	$class .=  ' current-cat-parent';
    }

    or exists something else astral situation like moonlight in last spring week…

    What are you trying to accomplish? I noticed that the category ID is 18, but you’re setting current_category to 1 in your call to wp_list_categories(). Also, I can reproduce your error if I set current_category to a number that doesn’t correspond to the ID of an existing category.

    Thread Starter Mihail D

    (@memberremember)

    i want to understand whats source line call notices
    so &current_category=1 is superfluous. Thats all. Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘wp_list_categories() – Trying to get property of non-object’ is closed to new replies.