Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

PHP Notice thrown if no created / published posts and requesting Custom Post Type #72

Closed
pvormittag opened this Issue · 1 comment

3 participants

@pvormittag

In this scenario, php returns a notice in which the $post object in wp-includes/post-template.php is null.

Notice:  Trying to get property of non-object in wp-includes/post-template.php on line 209

Again, the notice throws only when no posts are created / published and you are attempting to request a custom post type (ie wp-json.php/posts?type=custom_post_type)

Tested with:
WP 3.8.1
WP-API 0.8

@alisspers

I have this problem aswell, and it seems to me that it stems from the prepare_excerpt() method in class-wp-json-posts.php. The global $post is not set when doing get_the_excerpt(), resulting in a function in post-template.php trying to use $post->post_content when $post is null.

I'm sorry I haven't had time to investigate further to why this is happening. I just merely commented out the call to prepare_excerpt() (we don't use the excerpt anyway) and went on with it.

@rachelbaker rachelbaker added the Bug label
@rachelbaker rachelbaker added this to the 1.0 milestone
@rachelbaker rachelbaker self-assigned this
@rachelbaker rachelbaker removed their assignment
@rachelbaker rachelbaker modified the milestone: 0.9, 1.0
@rachelbaker rachelbaker self-assigned this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.