Advertisement
JTWilcox

Untitled

Jun 20th, 2011
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. // Pull PDF links from posts for category pages
  2. function pdf_links() {
  3.     global $wpdb;
  4.     $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
  5.     $attachment_url = wp_get_attachment_link($attachment_id);
  6.     if($attachment_id == NULL){
  7.         echo '';
  8.     } else {
  9.         echo wp_get_attachment_link($attachment_id, '' , false, false, 'Download PDF');
  10.         echo $attachment_url;
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement