• Hello,
    I am a plugin developer and one of my customers contacted me about the plugin not working with this theme. I investigated the problem and discovered theme was throwing the following error:

    • PHP Notice: Undefined offset: 0 in \wp-content\themes\simplenotes\functions.php on line 119
    • PHP Notice: Trying to get property of non-object in \wp-content\themes\simplenotes\functions.php on line 119
    • PHP Catchable fatal error: Object of class WP_Error could not be converted to string in \wp-content\themes\simplenotes\functions.php on line 120

    I looked into the code on these lines and saw that this theme assumes there will be a category assigned if the user is viewing a single post. My plugin uses custom post types and does not use the WP categories. A simple if-statement solves the problem by checking to see if the post does indeed have a category before trying to use it:

    $category = get_the_category();
    if ( count($category) > 0 ) {
           $category_id = get_cat_ID( $category[0]->cat_name );
           echo '<li> &nbsp; ► '. get_category_parents( $category_id, TRUE, "</li><li> &nbsp; ► " );
    } else {
    	echo "<li> &nbsp; ► ";
    }
    echo the_title('','', FALSE) ."</li>";
Viewing 1 replies (of 1 total)
  • Oh hey is this the fix? cause I am having this same exact problem right now!

    THANK YOU SO MUCH!!!! No one was answering me, and yest this work!

    • This reply was modified 7 years, 10 months ago by codyrauh.
Viewing 1 replies (of 1 total)
  • The topic ‘Theme fails on custom post types w/o a category’ is closed to new replies.