Exact image sizes

You’ll want to use add_image_size() in your functions.php to tell WordPress you’d like it to create a new image size when you upload images: add_image_size( ‘custom_image_size_name’, 290, 180, true ); Using the value true will tell WordPress you want it to crop the image to those exact dimensions. Once you do that and upload an … Read more

Get attached media only

All media (somewhat incorrectly) in the $wpdb->posts table will be “attachments” whether actually attached or not. “Attachments” that are actually attached will have a post_parent other than 0, so what you need are all of the attachments that have a 0 in the post_parent column, if I understand you. $args = array( ‘post_type’ => ‘attachment’, … Read more

How do I create Comma Separated list of attached image ids?

You can try this one-liner, within the loop, instead of all your above code: $ids = join( ‘,’, wp_list_pluck( get_attached_media(‘image’ ), ‘ID’ ) ); where we pluck out the ID’s from the get_attached_media() output. Another approach would be to use: $ids = join( ‘,’, get_attached_media( ‘_image_ids’ ) ); where we’ve introduced a new input parameter … Read more

Allowing post attachments without allowing to insert in text

One way to do this would be to simply hide the upload/insert media button: and, then add featured image support for your themes posts, so a user can still attach images to the post. Hide upload/insert media button for your theme in: functions.php: function hideUploadInsert($hook) { if($hook != ‘post.php’ AND $hook != ‘post-new.php’) return; // … Read more

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