I have 2 custom post types in WordPress: ‘homepage’ and ‘story’ and I have installed a plugin ‘Post from Site’. When I try to post into ‘story’ from front page with this plugin i get a few errors.
You can try too here: http://www.teenbetween.relationshipsireland.com/your-family-life/accepting-the-decision/ – you will find below image a link, use it.
And the article is posted but i get the error.
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/homepage.php on line 79
Notice: Undefined index: link_homepage in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/homepage.php on line 79
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/story.php on line 45
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1069
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1073
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1075
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1076
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1079
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/story.php on line 46 {"image":"none","error":"","success":"Post added, please wait to return to the previous page.","post":1139}
This is story.php 45:
if ( !current_user_can( 'edit_post', $post->ID )){
return $post->ID;
}
and homepage.php 79:
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "link_homepage", $_POST["link_homepage"]); // homepage.php 79
}
Any help please?
The
$post
object isn’t available during thesave_details
function. When you call the function, pass in the$post_id
as the first parameter. You’ll also want to move the authorization code instory.php
into thesave_details
function.See this for reference: http://codex.wordpress.org/Plugin_API/Action_Reference/save_post
If that doesn’t work you can try http://wordpress.org/extend/plugins/advanced-custom-fields/