Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Notice: Undefined index: error and understanding wordpress

First thing i see that needs to be changed is your assigining unchecked values to your input fields. Try wrapping isset round the variable before echoing, this will stop errors if they are not assigned or empty.

Second thing as you have passed a post id to get_post_custom() you dont need the second array.

function basin_manager_meta_options(){
    global $post;
    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
        return $post_id;

    $custom = get_post_custom($post->ID);
    if(isset($custom["source"])){
        $source= $custom["source"];
    }
    $author= $custom["author"];
    $date= $custom["date"];**

?>
    <style type="text/css">
        <?php include('basin-manager.css'); ?>
    </style>
    <div class="basin_manager_extras">
<?php
    $website= ($website == "") ? "http://" : $website;
?>
    <div><label>Website / Gazete ? :</label>
    <input name="source" value="<?php echo isset($source) ? source : ''; ?>" />
    </div>
    <div><label>Yazar:</label>
    <input name="author" value="<?php echo isset($author) ? $author : ''; ?>" />
    </div>
    <div><label>Date:</label>
    <input name="date" value="<?php echo isset($date) ? $date : ''; ?>" />
    </div>
<?php
}
add_action('save_post', 'basin_manager_save_extras');

function basin_manager_save_extras(){
    global $post;
    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
        //if you remove this the sky will fall on your head.
        return $post_id;
    } else {
        update_post_meta($post->ID, "source", $_POST["source"]);
        update_post_meta($post->ID, "author", $_POST["author"]);
        update_post_meta($post->ID, "date", $_POST["date"]);
    }
}

Related Posts:

  1. Query all posts where a meta key does not exist
  2. Can the Next/Prev Post links be ordered by menu order or by a meta key?
  3. what is the correct way to compare dates in a WP query_posts meta_query
  4. Advanced search form with filters for custom taxonomies and custom fields
  5. Meta query with boolean true/false value
  6. Get post with multiple meta keys and value
  7. Correctly delete posts with meta and attachments [duplicate]
  8. Storing revisions of metadata for custom post type
  9. Custom field values deleted when trashing custom post type
  10. How to get all custom fields of any post type
  11. Update CPT meta data using REST API
  12. Admin Area Custom Type Search By Meta Fields Without Title & Content
  13. Echo all meta keys of a custom-post TYPE
  14. Custom Post type – how to get checkbox to update meta field to null
  15. How can I filter posts by post_parent in the admin?
  16. How do I Paginate Search Results for Custom Post Types?
  17. How to throw error to user when saving post
  18. Ordering posts having multiple post-meta date fields
  19. Custom Post Type with Input fields to seperate table on database.
  20. How do I remove all the metaboxes for a custom post type?
  21. wordpress plugin error handling
  22. Custom Queries: Joining On Meta Values From Two Custom Post Types
  23. Gutenberg how to make attribute to save to meta
  24. How can I fix those issues generated by the Themecheck plugin
  25. Undefined property: stdClass::$labels in general-template.php post_type_archive_title()
  26. How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
  27. Post metadata deletes itself
  28. How to create a mini directory in WordPress?
  29. How Can I save multiple records in same meta key?
  30. Get all posts from custom post type and insert in select input as metabox
  31. Detect meta value changes when post is updated (post_updated)
  32. Search everything (posts, pages, tags, cpt, meta)
  33. Permalinks using event date (year & month) instead of publication date
  34. Custom Post Type: Set post_title equal to a custom post type field
  35. I can’t set meta_key in my custom post type query
  36. Grossly inefficient wordpress loops!
  37. Compare 3 custom fields and sort by oldest
  38. How Do I Use WP_Query to Run This Database Query as Search Result?
  39. WordPress Admin Panel search posts with custom post meta values along with title
  40. Creating a custom post type upon registration
  41. How to Update post status using meta data in Custom post TYpe
  42. The editor has encountered an unexpected error. // TypeError: Cannot read property ‘prefix’ of null
  43. Delete custom post type metadata without deleting the post in admin area
  44. Edit is changing my custom’s post type parent id
  45. Order by post meta value gets random results
  46. How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
  47. Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
  48. Disable Facebook Comments Automatically On CPT
  49. How to add post reference field to a plugin?
  50. meta query always fails even if data is correct
  51. Problem with ‘save_post’ hook not running
  52. WordPress custom post type
  53. Edit post meta direct from post.php?
  54. Howto: use existing post_meta as options for a different metabox (checkboxes or list)
  55. Custom Post Type meta oembed html output resulting in WSoD
  56. Values inside a custom field to determine which category posts to display
  57. How to create content automatically when a post is published?
  58. Display a post count from a custom metabox selection
  59. Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
  60. How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
  61. Rich Custom Field for Custom Post type not saving
  62. Add auto increment value to custom meta
  63. Custom post type submenu sorted by specific meta_key & meta_value
  64. Return only custom post types for the page, not all
  65. Change the contents of a dropdown through the admin panel?
  66. Advanced search form with filters for custom taxonomies and custom fields
  67. Retrieve post data via WPDB class
  68. Top 30 Songs using Custom Post Type
  69. Advice Needed for Post Meta Database Efficiency
  70. fetch meta fields inside a widget
  71. Querying meta values within an array
  72. Create action running on trashed_post hook to modify post_meta value
  73. Post AND page parameter for WP function
  74. Random meta field from specific custom post type
  75. Custom post type – update_meta not working
  76. Notices when submitting custom post type from front-end
  77. why get_post_meta is returning 0?
  78. Custom Post Type meta value is being saved in array, instead of just the string (as value)
  79. Save post_parent in a custom post type
  80. Custom Form Data save after Login User
  81. How to display Author Profile based on Custom field value
  82. Use a Variable in update_post_meta as the $meta_key
  83. Automatically add custom taxonomy when meta value gets to a set number or beyond
  84. Display a list of posts whose meta field values are equal to the ID of the post being viewed?
  85. Update an existing post in a custom post type
  86. Check for custom field value in different post type than current one and do something
  87. Changing to different post type maintains the redirection?
  88. Post Meta for Custom Post Types
  89. How do I add the “orange counter” next to a Custom Post Type?
  90. Custom Post Type slug has the same Redirection entry
  91. getEntityRecords/useEntityRecords: How to use CPT metadata?
  92. I am having a problem with fetching product data in the Gutenberg block editor
  93. CPT meta values intermittently return empty
  94. Quering a post object based on another related post object
  95. rest_api_init is not getting invoked inside a Class
  96. get_posts() return NULL using a custom plugin and add_submenu_page() with Post Type
  97. fehler beim laden des blocks: ungültige(r) parameter: attributes – Gutenberg
  98. Normal Posts and Custom Posts with Date Query
  99. Optimizing storage of Post Meta Entries
  100. Adding a new custom post type using the editor causes 502 bad gateway error
Categories custom-post-types Tags custom-post-types, errors, post-meta
Enter a variable in the ‘category_name’ parameter
Display data on same page as form without refresh

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress