New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breadcrumbs broken on empty post archives #443

Closed
javorszky opened this Issue Dec 11, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@javorszky

javorszky commented Dec 11, 2013

To reproduce

  • have WP_DEBUG turned on
  • Create a custom post type. I shall call mine mini-me.
  • Do not create any posts.
  • Navigate to the archive page, say http://localhost/sandbox/mini-me/ (depending on your permalinks and setup)
  • bask at the glory of this message: Notice: Trying to get property of non-object in /Users/yourusername/Sites/site/wp-content/plugins/wordpress-seo/frontend/class-breadcrumbs.php on line 321, and note that there is no last item on the breadcrumb

Reason

Internally it depends on get_post(), but since there are no posts, that will return false / null, thus it can`t get the post type of the post object, because the post object does not even exist.

@jdevalk

This comment has been minimized.

Member

jdevalk commented Dec 15, 2013

I can't reproduce it, where you using a specific theme?

BTW: it doesn't rely on get_post either, it relies on get_post_type_object, which is somewhat different :)

@javorszky

This comment has been minimized.

javorszky commented Dec 15, 2013

It's a custom post type archive, and the ptarchive key is set in the array with no content. That part of the code calls to WP's get_post_type() (https://github.com/Yoast/wordpress-seo/blob/master/frontend/class-breadcrumbs.php#L161) function, which either returns false or goes away to fetch the post with get_post( $post ) (https://github.com/WordPress/WordPress/blob/master/wp-includes/post.php#L1037).

The theme is custom that I'm writing from scratch.

@jdevalk

This comment has been minimized.

Member

jdevalk commented Dec 15, 2013

Ok it took a bit, but I reproduced it, fix coming in.

@jdevalk jdevalk closed this in caded2f Dec 15, 2013

@javorszky

This comment has been minimized.

javorszky commented Dec 15, 2013

Awesome, thank you :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment