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. Can the Next/Prev Post links be ordered by menu order or by a meta key?
  2. Custom field values deleted when trashing custom post type
  3. Custom Post type – how to get checkbox to update meta field to null
  4. How do I Paginate Search Results for Custom Post Types?
  5. Ordering posts having multiple post-meta date fields
  6. How do I remove all the metaboxes for a custom post type?
  7. Custom Queries: Joining On Meta Values From Two Custom Post Types
  8. How can I fix those issues generated by the Themecheck plugin
  9. How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
  10. Grossly inefficient wordpress loops!
  11. How Do I Use WP_Query to Run This Database Query as Search Result?
  12. Rest Api v2 orderby meta_key in custom post type
  13. Custom post type category not displaying in custom post type
  14. How to make custom post meta wp_editor translatable?
  15. How to add multiple featured image in meta box in post editor?
  16. update_post_meta() whenever custom post type is updated
  17. Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
  18. How to best delete orphan wp_postmeta
  19. Count posts with specific term_meta
  20. Custom search for custom post meta with pre_get_posts interferes with WP search
  21. WordPress Orderby Numeric Value Not Working
  22. Replace title column in post list with post meta value
  23. My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
  24. Does WordPress limit the length of slug names for Post Meta or Terms?
  25. Insert Multiple Post with Same Publish Button
  26. Undefined Variable – Custom Post Type Meta
  27. Ordering posts in Search & taxonomy by post_meta
  28. how to delete all users and posts based on ‘user_meta’?
  29. How to implement a Google map store locator
  30. changing meta value and meta key of price field
  31. Posting to a Custom Post Type from front end – user generated content
  32. Update Post Meta for a logged in user
  33. How to duplicate entire custom post type
  34. Restrict Access to Posts based on Custom User and Post Meta Data
  35. get_post_meta not working on publishing
  36. get_post_meta returning no value in custom post type alert email
  37. Custom fields for custom post type
  38. Is there a way to exclude posts based on meta_values?
  39. Submitting Custom Post Types with custom fields from Front-end form
  40. create custom meta box with default value
  41. How to Echo Metadata Value in Currency Format
  42. Filter posts by tax (dropdown) and meta value
  43. Publish and save specific postmeta to a filtered post_type
  44. How to move a post to different post type with all meta data?
  45. WP API Response does not show my registered metadata
  46. How to detect that the save_post hook is calling the callback associated to the current edit post page only
  47. Query not work for current taxonomy
  48. Batch Extract Date from post title and put into ACF custom field
  49. How to handle this specific case of custom post type?
  50. Save CTP post meta different values each day without overwriting previous values
  51. get_post_meta returns NULL in front-end, but correct result in back-end
  52. Problem with adding custom post type meta to header by plugin
  53. Meta box data is saved but NOT displayed in the meta box text field. Why?
  54. Echo custom post meta from options array
  55. Value of post meta dropdown is not showing in WordPress
  56. WP_Meta_Query object with conditionals
  57. Trying to write shortcode with get_post_meta but isn’t working
  58. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  59. HM CMB: Post Select Field for CPT ID
  60. Getting WordPress to store 0 values for custom post type meta
  61. Problem Saving Custom Post Type Meta Values
  62. Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
  63. Get_post_custom not fetching value from array wordpress
  64. Save data is post using php front end
  65. Creating a custom post type upon registration for a specific user role
  66. How to sort by multiple values in a nested WP_Query
  67. Where is get_post_meta value located?
  68. How do I create a customised table list of a custom post type (in the admin area)?
  69. Unknown Post Meta Records
  70. Get Previous Post based on Custom Field Name, for Custom Post Type
  71. Saving custom post types post_meta over REST-API fails
  72. add action save post type and update post meta woocommerce
  73. get_post_meta not working with variable as a post_id for dynamically get the postid
  74. How to save post_status using action save_post?
  75. Custom post meta box as a sub form
  76. Metaboxes in Loop
  77. Add more custom fields when creating a new custom post type
  78. Custom meta box data not saving
  79. Stripe multiple transactions
  80. Collect custom post in a calendar
  81. Storing data in a multidimensional array from dynamically generated foreach loop
  82. Edit is changing my custom’s post type parent id
  83. Disable Facebook Comments Automatically On CPT
  84. Problem with ‘save_post’ hook not running
  85. Howto: use existing post_meta as options for a different metabox (checkboxes or list)
  86. Values inside a custom field to determine which category posts to display
  87. Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
  88. How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
  89. Change the contents of a dropdown through the admin panel?
  90. Advanced search form with filters for custom taxonomies and custom fields
  91. Top 30 Songs using Custom Post Type
  92. Advice Needed for Post Meta Database Efficiency
  93. fetch meta fields inside a widget
  94. Querying meta values within an array
  95. why get_post_meta is returning 0?
  96. Save post_parent in a custom post type
  97. Use a Variable in update_post_meta as the $meta_key
  98. Update an existing post in a custom post type
  99. Custom Post Type slug has the same Redirection entry
  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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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