Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function widget_listattach($args) {
- global $wpdb, $post;
- extract($args);
- $options = array_merge(widget_listattach_options(), get_option('widget_listattach'));
- unset($options[0]); //returned by get_option(), but we don't need it
- $args = array(
- 'post_type' => 'attachment',
- 'post_mime_type' => $options['type'],
- 'numberposts' => $options['count'],
- 'orderby' => $options['orderby'],
- 'order' => $options['order'],
- 'post_parent' => $post->ID
- );
- $attachments = get_children($args);
- if ($attachments) {
- echo $before_widget . $before_title .$options['title'] . $after_title;
- echo '<ul>';
- foreach ($attachments as $attachment) {
- //echo '<li>'.$attachment->post_title.'</li>';
- //the_attachment_link($attachment->ID, false);
- $mime_parts = explode("/", $attachment-> post_mime_type);
- $mime_class = 'class="mime-'.$mime_parts[count($mime_parts)-1].'"';
- $descr = 'post_title';
- if ($options['display'] == 'caption') {
- $descr = 'post_excerpt';
- } else if ($options['display'] == 'description') {
- $descr = 'post_content';
- }
- if ($attachment->$descr) {
- echo '<li '.$mime_class.'><a href="'.wp_get_attachment_url($attachment->ID).'">'.$attachment->$descr.'</a></li>';
- } else {
- echo '<li '.$mime_class.'>'.wp_get_attachment_link($attachment->ID).'</li>';
- }
- }
- echo '</ul>'.$after_widget;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement