/** * @param bool $post_id * @param bool $width * @param bool $height * @param string $method * @param string $background */ function list_post_images($post_id = false, $width = false, $height = false, $method = 'crop', $background = 'FFFFFF') { $images = get_post_images($post_id); if (!empty($images)) { echo '<div class="wp-post-images"><ul class="list-wp-post-images">'; $i = 0; foreach ($images as $image) { $uploaddir = wp_upload_dir(); if ($width || $height) { $image_url = get_thumbnail(array('src' => $uploaddir['basedir'] . $image, 'width' => $width, 'height' => $height, 'method' => $method, 'background' => $background)); } else { $image_url = $uploaddir['baseurl'] . $image; } echo '<li class="post-image-item order-' . ++$i . '"><span><img src="' . $image_url . '" ' . ($width ? 'width="' . $width . '"' : '') . ' ' . ($height ? 'height="' . $height . '"' : '') . ' alt=""/></span></li>'; } echo '</ul></div>'; } }
function show_post_slider($content) { ?> <script> jQuery(document).ready(function($) { $("#slider").responsiveSlides({ auto: false, pager: false, nav: true, pause: true, namespace: "wp_post_slider" }); }); </script> <?php $sliderhtml = ''; $nPosts = 0; query_posts(array('orderby' => 'date', 'order' => 'DESC', 'showposts' => 5)); if (have_posts()) { $sliderhtml = '<h2>Latest Projects</h2>'; $sliderhtml .= '<div class="wp_post_slider_container"><ul class="rslides" id="slider">'; while (have_posts()) { the_post(); $imageURL = get_post_images(get_post()); if ($imageURl !== '') { $sliderhtml .= sprintf('<li><a href="%s" target="_blank">', get_permalink()); $sliderhtml .= sprintf('<img src="%s" alt="">', $imageURL); $sliderhtml .= sprintf('<p class="caption">%s</p></a></li>', get_the_title()); $nPosts++; } } $sliderhtml .= '</ul></div>'; } wp_reset_query(); return $nPosts > 0 ? $content . $sliderhtml : $content; }