How to get images only attached from edit post page

I´m using this code to load all images I uploaded via edit post page: function get_gallery_images(){ global $wpdb,$post; $ids = “”; $counter = 0; $number_of_posts = 12; $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => 12, ‘post_status’ => null, ‘orderby’ => ‘rand’, ‘post_parent’ => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as … Read more

Insert attachments from front end form

I found a working solution. This handles the uploaded files by attaching them to the post and display them in the loop. Still no featured image is set. if ( $_FILES ) { foreach ( $_FILES as $file => $array ) { $newupload = insert_attachment( $file, $pid_buy ); } } function insert_attachment( $file_handler, $post_id, $setthumb=’false’ … Read more

missing attachment are showing as 404

Although I see this question not specific to WordPress (at least the answer it’s not), I see similar questions posted in a regular basis and I think it is good to give a answer. If a URL doesn’t exist, in your case the URL is for a non-existant attachment, 404 is the correct HTTP status … Read more

When inserting attachments into a blog post, how can I get WordPress to use the full filename with the extension?

I figured out how to retitle the attachment myself, using a combination of the answers from these two posts: How can I add a default description to uploaded files? Change attachment filename Here’s the code, it’s working on my current WP installation (v4.3) function wpse_retitle_attachment( $post_ID ) { $file = get_attached_file($post_ID); $path = pathinfo($file); $args … Read more

Retrieve ONLY mp3s and set a variable for use in a playlist called by single.php template?

So here’s what I did to resolve this… I inserted the following code right after the loop started: <?php global $post; if( is_singular() && is_main_query() && $post->post_type === ‘download’ ) { $download = new EDD_Download( $post->ID ); $files = $download->get_files( ); $submission_attachment_ids=””; if ( is_array( $files ) ){ $first = true; foreach ( $files as … Read more

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