Delete attached images from posts

Having that resulting XML file from the export it’s just a matter of editing it precisely to get rid of the images before importing it on the other site. Taking Sublime Text for example it’s pretty easy to find and select all occurrences of [caption and add a line break before them for example. Same … Read more

Get post attachment with post id

yes use this code here you can get attachment id if(isset($_FILES[‘myimage’]) && ($_FILES[‘myimage’][‘size’] > 0)) { // Get the type of the uploaded file. This is returned as “type/extension” $arr_file_type = wp_check_filetype(basename($_FILES[‘myimage’][‘name’])); $uploaded_file_type = $arr_file_type[‘type’]; // Set an array containing a list of acceptable formats $allowed_file_types = array(‘image/jpg’, ‘image/jpeg’, ‘image/gif’, ‘image/png’); if (in_array($uploaded_file_type, $allowed_file_types)) { … Read more

How to restrict add media library only to images of the same post family?

You need to alter the query using posts_where and posts_join filters. function restrict_media_images_per_post_type($query) { add_filter(‘posts_where’, ‘media_posts_where’); add_filter(‘posts_join’, ‘media_posts_join’); return $query; } add_filter(‘ajax_query_attachments_args’, ‘restrict_media_images_per_post_type’); Change “WHERE” clause to restrict to specific post type to which selected post belongs to function media_posts_where($where) { global $wpdb; $post_id = false; $whitelist_post_type = array( ‘post’, ‘{custom post type}’ //change this … Read more

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