“Notice: Undefined index:” error when adding new content?

Whoever wrote your theme didn’t bother to verify the existence of array keys before using them. The error is happening because the key album_tracks_metabox_nonce doesn’t exist in the $_POST array. The line likely should be: if ( !isset($_POST[‘album_tracks_metabox_nonce’]) || !wp_verify_nonce($_POST[‘album_tracks_metabox_nonce’], ‘album_tracks_metabox’) ) { // whatever is in the if condition, likely `return` }

prevent post submission

See the Codex, on save_post. In answer to Question 1, it is fired whenever WordPress auto_saves a revision (i.e. hence when a post is edited). In particular, when creating a new post, wp-admin/post-new.php is loaded. WordPress then creates an auto draft even if you haven’t saved a draft or published to post. This is intended … Read more

Save checkboxes of a metabox with a foreach loop (invalid argument)

My advise would be to extract the query portion of your code: function get_brands() { $loop_brands = array(); wp_nonce_field( plugin_basename( __FILE__ ), ‘brands-nonce-field’ ); $args = array( ‘post_type’ => ‘page’, ‘post_parent’ => 7, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); $query_brands = new WP_Query($args); return $query_brands; } Then use it like this: function brands_save_meta_box( $post_id … Read more

Update post on save

A post’s title (post_title) is not saved in meta data; it’s a field within the post table. Here’s an updated version of your original code. Infinite loop is prevented by removing and then readding the wpse246957_update_post_info callback. Post title is successfully saved with the suffix – $post_id A check is in place to prevent the … Read more

Change 2 fields in the post depending on the 3rd field before save

Use the hook save_post and put an if inside the function that do the save after the ‘normal’ save meta fields routine. add_action( ‘save_post’, ‘this_is_the_function_name’ ); function this_is_the_function_name( $post_id ) { // No auto saves if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // make sure the current user can edit the post if( ! … Read more

Conflicting save_post functions when passing the post id and saving custom meta boxes for different post types

After doing some more research I found that: Instead of hooking the add_meta_box function into admin_menu it should be hooked into add_meta_boxes Instead of the foreach loop use the update_post_meta function on the save function Instead of using the wp_nonce_field the data can be sanitized using esc_attr and strip_tags To pass the post id to … Read more

How can i create a function to get youtube video time

The following are the functions that I use to extract data from a YouTube response to wp_remote_get. It’s just the basic stuff, you’ll have to adjust, complement and integrate into your code. add_action( ‘save_post’, ‘brsfl_save_postdata’ ); function brsfl_save_postdata( $post_id ) { // IMPORTANT! // Check for DOING_AUTOSAVE and wp_verify_nonce() $consult = brsfl_yt_api( $_POST[‘yt_id’] ); if( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)