Display a post attachment depending on the caption

Can you try something along these lines and report back the result? <?php if(qtrans_getLanguage()==’en’): ?> // attachment if statement <?php else if(qtrans_getLanguage()==’fr’): ?> // attachment if statement <?php endif; ?> Technically you could omit the second else if statement and replace it just with <?php else : ?> assuming you only have two languages you … Read more

Can’t sort get_posts by post_mime_type

As told by mrwweb you have to plug into Wp_Query orderby statement. add_filter( ‘posts_orderby’, ‘wpse53783_order_by_post_mime_type’ ); function wpse53783_order_by_post_mime_type( $orderby ) { global $wpdb; $order = substr( $orderby, strpos( $orderby, ‘ ‘ ) ); $orderby = “$wpdb->posts.post_mime_type $order”; return $orderby; } You can apply the filter before the query then remove it with: remove_filter( ‘posts_orderby’, ‘wpse53783_order_by_post_mime_type’ … Read more

Will wp_get_attachment_metadata display PDF metadata (eg: keyword, author, description)?

I’d say you’re gonna need external assistance… Zend Framework https://stackoverflow.com/a/4520725 $pdf = Zend_Pdf::load($pdfPath); echo $pdf->properties[‘Title’] . “\n”; echo $pdf->properties[‘Author’] . “\n”; XMP PHP Toolkit https://stackoverflow.com/a/8862702 XMP Toolkit PHP Extension is a PHP module which includes the Adobe XMP Toolkit SDK. This PHP5 extension will provide classes and methods to manipulate XMP Metadatas from files like … Read more

Display Audio Attachment URL

Assuming you do know the attachment $id, you can use wp_get_attachment_url(): <?php wp_get_attachment_url( $id ); ?> If you need to determine the attachment $id, you can use get_posts(): global $post; $audio_attachments = get_posts( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘audio’ ) ); If you have multiple (or unknown number of) audio attachments, … Read more

Upload image and assign it’s id to post

WordPress attachments are saved in the wp_posts table with the post_type field set to ‘attachment’. The post id for the post that the attachment is ‘linked’ to is in the post_parent field. Keep in mind that an attachment being ‘linked to a post is not really a solid connection. It is very possible to have … Read more

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