We have a 3rd party API. The entries of the API needs to be imported into a custom posttype.
The unfortunate thing is that I’m having some trouble with this.
Currently I am using this code:
$post = array(
'post_author' => 2,
'post_content' => "{$xml->opmerkingen}",
'post_name' => "{$xml->titel}",
'post_status' => 'publish',
'post_excerpt' => "{$xml->opmerkingen}",
'post_title' => "{$xml->titel}",
'post_type' => 'voertuig'
);
wp_insert_post($post);
And it is giving me these erros.
Notice: Trying to get property of non-object in wp-includes/post.php on line 3578
Notice: Trying to get property of non-object in wp-includes/link-template.php on line 49
Fatal error: Call to undefined function is_user_logged_in() in wp-includes/post.php on line 2066
I hope somebody could help me out with this!
Thanks in advance,
Sem
]]>Are you properly escaping quotes and other special characters in the values coming from your API?
Have you looked at what’s on line 3578 of wp-includes/post.php? That should tell you what value is breaking where.
]]>You’ll see many examples that require or include core files. This is doing it wrong. Explanation why and details on using admin-post.php can be found in this article.
]]>