use wp_get_attachment_image() to show attachments

You’re obviously getting data returned for $attachments = get_posts(); otherwise, you wouldn’t be able to output $attachment->post_title. So the issue must be with your wp_get_attachment_image() call. The first thing I would check is: why are you setting the $icon parameter to true? This parameter is intended to output a mime-type icon, instead of the actual … Read more

Change filename during upload

If you want to use the above sanitize_file_name filter, you could try this: function make_filename_hash($filename) { if( isset($_REQUEST[‘post_id’]) ) { $post_id = (int)$_REQUEST[‘post_id’]; }else{ $post_id=0; } $info = pathinfo($filename); $ext = empty($info[‘extension’]) ? ” : ‘.’ . $info[‘extension’]; $name = basename($filename, $ext); if($post_id>0){ return $post_id.”_”.$name . $ext; }else{ return $name . $ext; } } add_filter(‘sanitize_file_name’, … Read more

post_author for wp_insert_attachment

My question is, is there a way to add a post_author to the wp_insert_attachment? I could not find that in the documentation. I need the attachment to have the same author id as that of the post. Currently it takes the id of the the admin. Sometimes the codex or published docs don’t tell the … Read more

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