filter get_children to return all mime types EXCEPT ‘x’

Looks like this is two questions: how to get all the children that are audio, and how to get all the children that aren’t audio. 1) The post_mime_type parameter of get_children can actually take a wildcard, so you could use: $children = get_children(array( ‘post_parent’ => $post->ID, ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_mime_type => ‘audio/%’ … Read more

Create page from post attachments

You can. I think, you should do that with page-template. For that, create a page template. Easiest way is: 1) Inside your theme folder, make a duplicate of page.php and name it i.e. my-page.php 2) open that file and in the top, after <?php place this: /** * Template Name: my templt for attchmnts */ … Read more

Auto create file and send it via wp_mail()

Can’t help you with the creation of the .doc-file, as i have never done that. But if you manage to get the encoded file into a string, you can work with the WordPress PHP-Mailer instance like this: function send_my_mail_with_attachment($from,$to,$subject,$body,$attachmentstring=””){ global $phpmailer; // (Re)create it, if it’s gone missing if ( ! ( $phpmailer instanceof PHPMailer … Read more

Proper use of wp_get_attachment_image?

Don’t you need to use get_posts( ‘post_type=attachment’ ) to return the attachment IDs? So, something like: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); $myimageid = $attachments[0]->ID; wp_get_attachment_image( $myimageid, ‘full’ ); Otherwise, you’re using $post->ID of 1, which isn’t likely to work.

How can I make an attachment page for pdf uploads?

You can use pdf.php or a number of other specially-named template files as described birgire’s answer to show an attachment page specifically for PDFs, or use a generic attachment.php page that includes conditional statements for the type of attachment (like the code in your question does). Potential Conflict with Yoast SEO Plugin Note that attachment … Read more

How do you create an attachment ID with Ajax submit? No page refresh

Here’s my solution for creating an attachment ID with a temporary title and the post_parent which it is attached to. My jQuery psuedo code, without the needless stuff: jQuery(‘.addImage’).live(‘click’, function() { jQuery.ajax({ type: ‘post’, url: ajaxurl, data: { action: ‘save_attachment’, _ajax_nonce: jQuery(‘#nonce_add’).val(), post_parent: jQuery(‘#post_ID’).val(), attach_title: ‘Attachment ‘ + size }, success: function( res ) { … Read more

How to allow empty title for attachments?

Without a post title, Attachments become significantly harder to use as they no longer have a title that can be clicked on. If you’re processing attachments and generating html manually I recommend using another piece of attachment meta, or just filling in appropriate titles, after all an image is a picture of something, let that … Read more

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