Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?

It seems that in the recent releases of WordPress, changes were made to the mime type handling to make sure that files have the extension they say they do: https://make.wordpress.org/core/2018/12/13/backwards-compatibility-breaks-in-5-0-1/ This poses an issue for SVG files without the tag in them. SVG is actually an XML, and WordPress is now requiring to have a … Read more

Easy way to delete 70k posts and attached media?

If you know how to find the posts, then we can use WP CLI to do a 2 step process. First, grab all the post IDs in those categories using wp post list E.g. posts=$(wp post list –field=”ID” –category__in=”1,2,etc”) wp post delete $posts –force Then we can plug the values in posts into wp post … Read more

Get image alt attribute just by image URL

Using the function found here, you could add this to your functions.php // retrieves the attachment ID from the file URL function pippin_get_image_id($image_url) { global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare(“SELECT ID FROM $wpdb->posts WHERE guid=’%s’;”, $image_url )); return $attachment[0]; } But to use it, you need the full image URL. $img_url = get_bloginfo(‘url’) . “https://wordpress.stackexchange.com/bc/wp-content/uploads/placeholder-image.png”; if … Read more

Getting alt text of featured image

The alt text is stored as post meta on the attachment, and can be retrieved with get_post_meta() combined with get_post_thumbnail_id(): <?php echo get_post_meta( get_post_thumbnail_id(), ‘_wp_attachment_image_alt’, true ); ?> But if you just use the the_post_thumbnail() function then you don’t need to bother, the img tag will be output for you, with the alt text: <?php … Read more

How to insert an Audio Player in a Post or Page?

Plugin option When searching for a plugin, it is important to check: Compatible up to, supports current WordPress version? Last updated, too long ago? Support, too many bug reports? Level of support in the forum or in the official plugin page. Compatibility, if the plugin hasn’t been updated for a while or is not compatible … Read more

WordPress 3.5 Media Manager – add a button

This block of code will add a button right next to the “Insert into post” one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML: var wpMediaFramePost = wp.media.view.MediaFrame.Post; wp.media.view.MediaFrame.Post = wpMediaFramePost.extend( { mainInsertToolbar: function( view ) { “use strict”; wpMediaFramePost.prototype.mainInsertToolbar.call(this, view); var controller = this; this.selectionStatusToolbar( view … Read more

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