Differentiate Featured Image from Post Images upon Upload

You could do this by filtering the meta value for _thumbnail_id. add_filter( ‘update_post_metadata’, ‘generate_featured_image_sizes’, 10, 5 ); add_filter( ‘add_post_metadata’, ‘generate_featured_image_sizes’, 10, 5 ); function generate_featured_image_sizes( $check, $object_id, $meta_key, $meta_value, $unique_or_prev ) { if ( $meta_key == ‘_thumbnail_id’ ) { // regenerate previous featured image thumbs if it exists if ( false !== ( $prev_thumb_id = … Read more

“Add Media” only shows “Full Size” under Attachment Display Settings

In order to show new image dimension options in the WordPress admin media library you would need to use the image_size_names_choose filter to assign them a name. So the code in your functions.php should look something like this: if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘single-post-medium’, 515 ); add_image_size( ‘single-post-small’, 250 ); } add_filter( … Read more

Change WordPress upload path and URL

I went to the wp-admin/options.php page and set … But is that how it’s supposed to be done? Nope. You should never change anything in the WordPress core files because all your changes will be lost during the next update. You should use actions and filters instead: add_filter( ‘pre_option_upload_path’, function( $upload_path ) { return ‘/path/to/static’; … Read more

How to add more upload directories?

The following code will change the upload directory for a specific post-type! Just be sure to swap out both instances of “post-type” (line 14) with the name of your custom post-type. /** * Change Upload Directory for Custom Post-Type * * This will change the upload directory for a custom post-type. Attachments will * now … Read more

Allow CSV files to be uploaded

There’s a bug in WordPress 4.7-4.7.3 related to validating MIME types, so the code provided by Dave Romsey won’t work. There’s a plugin in the repo that will bypass MIME checks, but it disables the checks for all users and all extensions. I think a better way would be to add a new capability for … Read more

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