Getting attachment post using wp_get_attachment_link

Yes, if you pass third ($permalink) parameter as true in wp_get_attachment_link() image will link to attachment’s page not image itself. You can use wp_get_attachment_link filter to change behavior of that parameter, but in this case it simply means overwriting whole function. Instead I would use wp_get_attachment_image() and get_permalink() UPDATE Maybe wp_get_attachment_image() would fit in this … Read more

How d0 i get the number of attachments in the post

Use following code to do the work : global $post; $page_id = $post->ID; $all_attachments = get_posts( array( ‘post_type’ => ‘attachment’,’post_mime_type’ => ‘image’, ‘post_parent’ => $page_id, ‘post_status’=>’published’, ‘numberposts’ => -1 ) ); $no_of_photos = count($all_attachments); // Gets the number of photo’s attached in $no_of_photos variable $first_img_URL = get_permalink($all_attachments[0]->ID); // Gets the URL of first attachment in … Read more

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

Is there a way to show attachment IDs on the attachment info screen?

You could hook into ‘attachment_fields_to_edit’ and just add a row: <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Show Attachment ID * Version: 2012.06.04 * Author: Thomas Scholz <[email protected]> * Author URI: http://toscho.de * License: MIT * License URI: http://www.opensource.org/licenses/mit-license.php */ if ( ! function_exists( ‘t5_show_attachment_id’ ) ) { add_filter( ‘attachment_fields_to_edit’, ‘t5_show_attachment_id’, … Read more

List WordPress Post and Related Attachments outside of a post page

First of all don’t use query_posts function, use the WP_Query class instead. Secondary you forget to fetch attachments for a post. You can get attachments list by calling get_children function. $args = array ( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘audio’, ‘numberposts’ => -1, ); $the_query = new WP_Query( ‘portfolio-tags=apple&post_type=portfolio&posts_per_page=-1&orderby=title&order=asc’ ); if ( $the_query->have_posts() ) : … 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

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