PluginProbe
WP Attachments / 2.0
WP Attachments v2.0
6.0.2 6.0.3 trunk 2.0 3 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.2 3.2.1 3.2.2 3.2.3 3.2.4 3.3 3.4 3.5 3.5.1 3.5.2 3.5.3 3.5.4 All 52 releases
wp-attachments / wp-attachments.php

wp-attachments.php in WP Attachments 2.0, at wp-attachments.php

37 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP-Attachments
4 Plugin URI: http://www.milesimarco.altervista.org/wp-attachments
5 Description: Automatically shows your doc, xls and pdf attachments under every post and page. Simply and Easily. As it should be!
6 Author: Marco Milesi
7 Version: 2.0
8 Author URI: http://www.milesimarco.altervista.org/
9 */
10
11 add_filter( 'the_content', 'wpatt_content_filter' );
12 function wpatt_content_filter( $content ) {
13 global $post;
14
15 $attachments = get_posts( array(
16 'post_type' => 'attachment',
17 'post_mime_type' => 'application/pdf,application/msword,application/msexcel',
18 'posts_per_page' => 100,
19 'post_parent' => $post->ID
20 ) );
21
22 if ( $attachments ) {
23 $content .= '<h2>Attachments:</h2>';
24 $content .= '<ul class="post-attachments">';
25 foreach ( $attachments as $attachment ) {
26 $class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
27 $title = wp_get_attachment_link( $attachment->ID, false );
28 $content .= '<li class="' . $class . '">' . $title . '</li>';
29 }
30 $content .= '</ul>';
31 }
32
33 return $content;
34 }
35
36
37 ?>