Upload image to wordpress

Output during saving You can not print something during the data is saved. If you use die( var_dump( $your_var ) ); it will print the values, but also stops the script. The reason is, first the data will be parsed. Then you will be redirected back to profile.php. So everything you print while parsing the … Read more

Changing upload directory for plugin uploads only

There must be something identifiable about your form data, such as your input names. Check for one or more of those and process accordingly. function custom_upload_dir($args) { if (isset($_POST[‘something’])) { $args[‘path’] = $args[‘basedir’] . “/mypath” . $args[‘subdir’]; $args[‘url’] = $args[‘baseurl’] . “/mypath” . $args[‘subdir’]; } return $args; } After some investigation, the only things I … Read more

Media upload in add comment meta box

You could start with this : add_action( ‘comment_form_logged_in_after’, ‘wpse_102612_additional_fields’ );// only for logged users function wpse_102612_additional_fields () { echo ‘<p class=”comment-form-upload”>’. ‘<label for=”upload”>’ . __( ‘Upload your file’ ) . ‘</label>’. ‘<input id=”upload” name=”upload” type=”file” size=”30″ /></p>’; }

Import existing image as a single post

See my answer here: The Media Library lives in both wp_posts and wp_postmeta. wp_postmeta contains the image URL wp_posts contains an entry for each image insertion into a post, along with the post ID. Exporting and importing these 2 tables as SQL did not work for me – I received ‘duplicate entry for key 7’… … Read more

Media Upload Directory to MMYY instead of YYYY/MM

/** Force wp_upload_dir() to use time-based paths. */ add_filter( ‘pre_option_uploads_use_yearmonth_folders’, ‘__return_true’ ); /** * Use the date format MMYY instead of YYYY/MM in the uploads path. * * @param array $dir * @return array */ function wpse_104005_upload_dir( $dir ) { if ( preg_match( ‘!/([0-9]{4})/([0-9]{2})!’, $dir[‘subdir’] ) ) { // Check we do indeed have a … Read more

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