/** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { // outputs the content of the widget echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } $number_of_posts = -1; if (!empty($instance['show_number_files'])) { $number_of_posts = $instance['show_number_files']; } $orderby = 'date'; if (!empty($instance['sort_parameter'])) { $orderby = $instance['sort_parameter']; } $order_direction = 'DESC'; if (!empty($instance['sort_direction'])) { $order_direction = $instance['sort_direction']; } $exclude_ids = array(); if (!empty($instance['exclude_ids'])) { $exclude_ids = $instance['exclude_ids']; } // TODO: get template choice. Echo css based on choice echo '<style>.list_mediafiles_box{'; echo 'border: 1px solid #e2e2e2;'; echo 'margin: 5px;'; echo 'padding: 5px;'; echo '} .list_mediafiles_box img{'; echo 'max-width:100px;'; echo '} </style>'; $args = array('post_type' => 'attachment', 'numberposts' => $number_of_posts, 'post_status' => null, 'post_parent' => null, 'orderby' => $orderby, 'order' => $order_direction, 'exclude' => $exclude_ids); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $post) { echo '<div class="list_mediafiles_box">'; setup_postdata($post); echo '<h4>' . get_the_title($post->ID) . '</h4>'; switch ($post->post_mime_type) { case 'image/jpeg': case 'image/png': case 'image/gif': the_attachment_link($post->ID, false); break; default: echo '<a href="' . get_attachment_link($post->ID) . '"><img src="' . wp_mime_type_icon($post->post_mime_type) . '"></a>'; } echo '<span class="aligncenter" style="word-break:break-word;">'; the_excerpt(); echo '</span>'; echo '</div>'; } } //echo $args['after_widget']; }
function jlc_get_attachements($pid) { $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $pid); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $post) { setup_postdata($post); the_attachment_link($post->ID, false, false, true); } } }
function batch_update_image_tags_easy() { $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $post) { setup_postdata($post); the_title(); the_attachment_link($post->ID, false); the_excerpt(); } } }
<div <?php bf_post_class(); ?> > <?php bf_postheader(); ?> <div class="entry-content"> <?php bf_postmeta(); ?> <div class="attachment"><?php the_attachment_link($post->post_ID, false); ?> </div> <?php the_content(__('<p>Read the rest of this entry »</p>', 'buffet')); ?> <?php wp_link_pages(array('before' => __('<p><strong>Pages:</strong> ', 'buffet'), 'after' => '</p>', 'next_or_number' => 'number')); ?> </div><!-- .entry-content --> <?php bf_postfooter(); ?>
} elseif (is_tax('events')) { echo "<h1>Pictures from: {$term->name}</h1>"; echo "<p>{$term->description}</p>"; } elseif (is_tax('places')) { echo "<h1>Pictures at: {$term->name}</h1>"; echo "<p>{$term->description}</p>"; } elseif (is_tax()) { echo "<h1>Galleries of the type: {$term->name}</h1>"; echo "<p>{$term->description}</p>"; } ?> <div class="post taxonomy-index-gallery"><center><?php foreach ($attachments as $attachment) { setup_postdata($attachment); the_attachment_link($attachment->ID, false, null, 1); the_excerpt(); } ?> </center></div> <br /> <hr> <?php } global $wp_query; $args = array_merge($wp_query->query_vars, array('cat' => $gallery_id)); query_posts($args); if (have_posts()) { if (is_tax('people')) { if ($term->description != "") { $term_name = $term->description;
<div id="post-<?php the_ID(); ?> " class="<?php thematic_post_class(); ?> "> <?php // creating the post header thematic_postheader(); ?> <div class="entry-content"> <div class="entry-attachment"><?php the_attachment_link($post->post_ID, true); ?> </div> <?php the_content(more_text()); wp_link_pages('before=<div class="page-link">' . __('Pages:', 'thematic') . '&after=</div>'); ?> </div> <?php // creating the post footer thematic_postfooter(); ?>
function show_post_attachment($id) { $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $id); $attachments = get_posts($args); if ($attachments) { ?> <dl style="border: solid 1px #ccc; padding: 10px;"> <dt>Files for this post</dt> <?php foreach ($attachments as $attachment) { ?> <dd><?php the_attachment_link($attachment->ID, false); ?> </dd> <?php } ?> </dl> <?php } }
function cxseries_list_results() { global $post; $tags = get_tags(array("get" => "all", "orderby" => "name", "order" => "desc")); if ($tags) { foreach ($tags as $tag) { if (preg_match('/[0-9]{4}/', $tag->name)) { wp_reset_postdata(); $the_query = cxseries_fetch_results($tag->name); if ($the_query->have_posts()) { echo "<h3>" . $tag->name . "</h3>"; echo "<ul>"; // The Loop $post_count = 0; while ($the_query->have_posts()) { $the_query->the_post(); ?> <li><?php the_attachment_link(); ?> </li> <?php $post_count++; } echo "</ul>"; } else { echo "<p>No results posted!</p>"; } wp_reset_postdata(); } } } // TODO // get list of tags that match year format // cycle through each tag and query individually wp_reset_postdata(); }
the_post(); ?> <h2><?php the_title(); ?> </h2> <p class="em"><?php printf(__('By %1$s<br />Posted on %2$s at %3$s', 'mim'), get_the_author(), the_date('', '', '', false), get_the_time()); edit_post_link(__('Edit', 'mim'), ' | ', ''); ?> </p> <?php if (is_attachment()) { ?> <?php the_attachment_link($post->ID, false, array(60, 80)); } else { ?> <?php the_content(); ?> <?php wp_link_pages('before=<p class="pp">' . __('Pages: ', 'mim') . '&after=</p>'); } ?> <p class="em"><?php printf(__('Categories: %1$s%2$s', 'mim'), get_the_category_list(' | '), get_the_tag_list(__('<br />Tags: ', 'mim'), ' | ', '')); ?> </p> <?php if ('open' == $post->comment_status) {
function the_post_image_collage() { $media = get_attached_media('image', get_the_ID()); foreach ($media as $image) { // echo '<div class="image">'; the_attachment_link($image->ID); // echo '</div>'; } }
while ($query->have_posts()) { $query->the_post(); // Get thumbnail of our news, chooses first one to be uploaded $args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => 'any', 'post_parent' => $post->ID, 'orderby' => 'date', 'order' => 'ASC'); $attachments = get_posts($args); echo '<article>'; echo '<header>'; echo '<h2><a href=".' . get_permalink() . '">' . get_the_title() . '</a></h2>'; echo '<h3>' . get_the_date() . '</h3>'; echo '</header>'; if ($attachments) { ?> <figure class="alignleft"> <?php the_attachment_link($attachments[0]->ID, false); ?> </figure> <?php } echo the_excerpt(); ?> <footer> <?php $categories_list = get_the_category_list(__(', ', 'hmc')); if ($categories_list) { ?> <p class="cat-links">
</div> <div class="tl-content"><?php the_content(); ?> </div> <div class="tl-attachments"><?php $args = array('post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post->ID); $attachments = get_posts($args); if ($attachments) { ?> <ol> <?php foreach ($attachments as $attachment) { ?> <li><?php the_attachment_link($attachment->ID, false); ?> </li> <?php } ?> </ol> <?php } ?> </div> </li> <?php } } ?>