Custom “radio button meta box” not saving correctly

The error is in you saving function where you are looking for $_POST[‘meta_box_musicreleases_linktype’] which is never set and should actually be $_POST[‘linktype’], and the use of wp_kses is not right here, if you want to validate the data and you know all of the accepted values the you can simply use in_array try: add_action( ‘save_post’, … 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

Meta Box on Custom Post Type not saving

Hi @George Wiscombe: So close, yet so far! (I know the pain, I’m there often. 🙂 You almost had it but are using the wrong hook to do the post meta update. Use the ‘wp_insert_post_data’ hook instead of the ‘save_post’ hook: <?php if (!class_exists(‘YourSite_Portfolio’)) { class YourSite_Portfolio { static function on_load() { add_action(‘init’,array(__CLASS__,’init’)); add_action(“admin_init”,array(__CLASS__,’admin_init’)); add_action(‘wp_insert_post_data’,array(__CLASS__,’wp_insert_post_data’),10,2); … 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

“Discussion” checkboxes unchecked by default on pages? [duplicate]

You can re-register the “page” post type and leave out the comments capability. add_action( ‘init’, ‘my_new_page_type’ ); function my_new_page_type() { register_post_type( ‘page’, array( ‘labels’ => array( ‘name_admin_bar’ => _x( ‘Page’, ‘add new on admin bar’ ), ), ‘public’ => true, ‘publicly_queryable’ => false, ‘_builtin’ => true, /* internal use only. don’t use this when registering … 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!

WordPress from url get external source title

Here you go: class UrlToTitleConverter{ public function convert($Url){ $response = wp_remote_get($Url); if ( is_array( $response ) ) { $body = $response[‘body’]; $title = substr($body, strpos($body, ‘<title>’)+7); $title = substr($title, 0, strpos($title, ‘</title>’)); } return $title; } }