PHP Notice: Undefined index: mytheme_meta_box_nonce

You should always check if a POST variable (or an item/key in an array like the superglobal $_POST variable) exists before attempting to use it. And you could use isset() like so: if ( // Check if the variable is set. isset( $_POST[‘mytheme_meta_box_nonce’] ) && // .. before accessing the value. ! wp_verify_nonce( $_POST[‘mytheme_meta_box_nonce’], basename( … Read more

Condition display metabox in case the post is saved

As an alternative to @m0r7if3r’s solution, the add_meta_boxes hook optionally passes two variables, the post type and post object. You can use this to conditionally add your metabox. New posts have the post status of ‘auto-draft’. add_action( ‘add_meta_boxes’, ‘myplugin_add_custom_box’,10,2); function myplugin_add_custom_box($post_type, $post) { if($post->post_status != ‘auto-draft’){ add_meta_box( ‘myplugin_sectionid’, __( ‘My Post Section Title’, ‘myplugin_textdomain’ ), … Read more

How to add meta box for image upload using WordPress media uploader?

I found the best solution please check it: jQuery Code jQuery(function($){ /* * Select/Upload image(s) event */ $(‘body’).on(‘click’, ‘.misha_upload_image_button’, function(e){ e.preventDefault(); var button = $(this), custom_uploader = wp.media({ title: ‘Insert image’, library : { // uncomment the next line if you want to attach image to the current post // uploadedTo : wp.media.view.settings.post.id, type : … Read more

Add custom action in post type

I found this solution here: WP plugin that add a button to post edit page that allow sending a notify to a contributor whose a post was not approved. It’s possible customize the message including the reason for rejected approval. https://github.com/Giuseppe-Mazzapica/GMRejectNotify I have not tested it but it seems legit!

how can i do metabox [closed]

ID; $meta_value = get_post_meta($post_id, ‘episodes’, true); ?> <label for=”episodes”>Bölüm Sayısı Örnek 1.Bölüm:</label> <div> <input type=”text” name=”episodes” value=”<?php echo $meta_value; ?>” id=”episodes” /> </div> ID; if (isset($_POST[‘episodes’]) && !empty($_POST[‘episodes’])) { update_post_meta($post_id, ‘episodes’, $_POST[‘episodes’]); } else { delete_post_meta($post_id, ‘episodes’); } } add_action(‘save_post’, ‘bolumler_save’); See my teacher, I created one but I can use only one of them. … Read more