How to delete file uploaded by Plupload

To delete a file from the file system, you can use something like this attached to an AJAX hook that is called by jQuery: function ajax_remove_image() { check_ajax_referer( ‘image_removal’, ‘image_removal_nonce’ ); if ( ! $_POST[ ‘confirm’ ] ) exit( ‘false’ ); $uploads = wp_upload_dir(); $upload_dir = $uploads[ ‘path’ ]; $file = strpos( $_POST[ ‘file’ ], … Read more

Custom wpdb query – how to sort post by another table meta_count

<?php $querystr = “SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_title, {$wpdb->prefix}stt2_meta.meta_count FROM {$wpdb->posts}, {$wpdb->prefix}stt2_meta WHERE {$wpdb->posts}.post_type=”post” AND {$wpdb->posts}.post_status=”publish” AND {$wpdb->posts}.ID IN ( SELECT post_id FROM {$wpdb->prefix}stt2_meta ) ORDER BY {$wpdb->prefix}stt2_meta.meta_count DESC LIMIT 10;”; $pageposts = $wpdb->get_results($querystr, OBJECT); ?>