Created
December 13, 2013 06:33
-
-
Save ravinsharma12345/7940568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Callback for WordPress 'post_edit_form_tag' action. | |
* | |
* Append enctype - multipart/form-data and encoding - multipart/form-data | |
* to allow image uploads for post type 'post' | |
* | |
* @global type $post | |
* @return type | |
*/ | |
function my_post_edit_form_tag(){ | |
global $post; | |
// if invalid $post object, return | |
if(!$post) | |
return; | |
// get the current post type | |
$post_type = get_post_type($post->ID); | |
// if post type is not 'post', return | |
if('post' != $post_type) | |
return; | |
// append our form attributes | |
printf(' enctype="multipart/form-data" encoding="multipart/form-data" '); | |
} | |
add_action('post_edit_form_tag', 'my_post_edit_form_tag'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment