New posts getting error of "Trying to get property of non-object"
-
Getting PHP warning when adding a new post. Trying to get property of non-object in… Undefined index: projLink and also tools.
What do I need to fix in my code? I know Its telling me projLink and tools is not set. Thanks.
function portfolio_meta_options(){ global $post; if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; $custom = get_post_custom($post->ID); $link = $custom["projLink"][0]; $tools = $custom["tools"][0]; ?> <label>Link:</label><input name="projLink" value="<?php echo $link; ?>" /><br /> <label>Tools:</label><input name="tools" value="<?php echo $tools; ?>" /> <?php } add_action('save_post', 'save_project_link'); function save_project_link(){ global $post; if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){ return $post_id; }else{ update_post_meta($post->ID, "projLink", $_POST["projLink"]); update_post_meta($post->ID, "tools", $_POST["tools"]); } } add_filter("manage_edit-portfolio_columns", "project_edit_columns"); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘New posts getting error of "Trying to get property of non-object"’ is closed to new replies.