“Organize my uploads into month- and year-based folder” Option Not Visible in Multisite

All credit to: https://chiroiu.com/blog/disable-month-year-based-uploads-on-wordpress-multisite/ Disable month- / year-based uploads on wordpress multisite Wordpress / January 30, 2020 By default wordpress organises uploaded media into month- and year-based folders. Probably a relict from when it was mostly used as a blogging tool. You can disable this easily enough under Settings > Media. On a WordPress Multisite … Read more

Media library style not loading correctly when selecting a page featured image?

After some search, the problem was in the pages which contains ACF blocks ACF plugin is not compatible with the latest WP 5.9.1 temporary fixes until the update has been released : 1- In your functions.php file add these lines: function acf_fix_preload_path( $preload_paths ) { global $post; $rest_path = rest_get_route_for_post( $post ); $remove_path = add_query_arg( … Read more

Fallback media image for featured image not working in admin column

wp_get_attachment_image_src(156, ‘archive_thumbnail’)[0] will only echo the URL of the image. You need to add it to html to display the image. Try this: echo ‘<img src=”‘.wp_get_attachment_image_src(156, ‘archive_thumbnail’)[0].'”/>’; You could add the width etc as well echo ‘<img src=”‘.wp_get_attachment_image_src(156, ‘archive_thumbnail’)[0].'” width=”.wp_get_attachment_image_src(156, ‘archive_thumbnail’)[1].” height=”.wp_get_attachment_image_src(156, ‘archive_thumbnail’)[2].” />’; what happens if someone deletes this image though? Do you have … Read more

Custom “Insert into Post” button

If you want it to show up in the image edit, say next to “insert into post” you will need to hook into attachment_fields_to_edit //for instance add_filter( ‘attachment_fields_to_edit’, ‘yourfunction’, 1, 2 ); Have a look at media.php http://mobile.adambrown.info/p/wp_hooks/hook/attachment_fields_to_edit?version=3.1&file=wp-admin/includes/media.php

How to fetch only media that was already attached to a post/page?

A similar approach to your post_parent idea is to add a filter to posts_where: function bbg_filter_out_non_attachments( $sql ) { global $wpdb; // Maybe do some conditional logic to decide whether to filter this query, then… return $sql . ” AND $wpdb->posts.post_parent != 0 “; } add_filter( ‘posts_where’, ‘bbg_filter_out_non_attachments’ ); Another technique is to do a … Read more