• I’m building a custom theme for my portfolio and learning as I go. I made a rookie mistake which I desperately need assistance with.

    My theme will has both default and custom posts with categories that will be queryable and displayed on separate pages. The default post category queries go to category.php, but the the custom post’s were giving a 404, which I was in the process of working out. For some reason one of the custom post categories would send me to category.php and display a default post that wasn’t even an active post in my admin panel. It was something I had either deleted or changed.

    I decided to make sure everything was cleared out so I deleted all of these posts from the phpMyAdmin panel. I accidentally also deleted the blog page as well. I created a new blog page and menu item for it and now I get these errors

    Warning: Creating default object from empty value in /Applications/MAMP/htdocs/wordpress6/wp-admin/includes/nav-menu.php on line 407

    Notice: Undefined property: stdClass::$ID in /Applications/MAMP/htdocs/wordpress6/wp-admin/includes/nav-menu.php on line 410

    This is the function that it’s referring to. The first line code starts on line 405 of the file:

    if ( ! empty( $posts_page ) ) {
    			$posts_page_obj             = get_post( $posts_page );
    			$posts_page_obj->posts_page = true;
    
    			$important_pages[]   = $posts_page_obj;
    			$suppress_page_ids[] = $posts_page_obj->ID;
    		}

    I really don’t know where to start with this or why I’m getting it since I simply replaced the page and menu link with the same thing that was deleted. I’m doing this locally on MAMP btw.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lgehrig4

    (@lgehrig4)

    Update: I took the easy way out. Created a new instance/database and copied all the files over.

    I would still like to understand what I may have done, and even try to fix the old site if anyone has suggesstions.

    Moderator bcworkz

    (@bcworkz)

    I think it was because you have your site set to display a “static” front page, but you did not specify a “posts” page for use in showing a blog listing. Even if you don’t intend to use it, you have to specify one. Maybe at one time you did have a page set for posts, but if you then deleted that page, it’d be as though one was never specified.

    Thread Starter lgehrig4

    (@lgehrig4)

    Yes, that was it. Didn’t even think to revisit that after I had deleted the page and replaced it. At least I know this for the future. Thx!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with -> Warning: Creating default object from empty value’ is closed to new replies.