Last active
December 28, 2015 12:28
-
-
Save andrescifuentesr/7500420 to your computer and use it in GitHub Desktop.
WordPress: slider with responsive-slides.viljamis.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_parent' => $post->ID, // For the current post | |
'post_type' => 'attachment', // Get all post attachments | |
'post_mime_type' => 'image', // Only grab images | |
'order' => 'ASC', // List in ascending order | |
'orderby' => 'rand', // List them in their menu order | |
'numberposts' => -1, // Show all attachments | |
'post_status' => null, // For any post status | |
); | |
// Retrieve the items that match our query; in this case, images attached to the current post. | |
$attachments = get_posts($args); ?> | |
<?php // If any images are attached to the current post, do the following: ?> | |
<?php if ($attachments) { ?> | |
<!-- Slideshow 2 --> | |
<div class="callbacks_container"> | |
<ul class="rslides" id="slider-index"> | |
<?php // Now we loop through all of the images that we found ?> | |
<?php foreach ($attachments as $attachment) { ?> | |
<!-- Set the parameters for the image we are about to display. --> | |
<?php $default_attr = array( | |
'alt' => trim(strip_tags( $attachment->post_title )), | |
); | |
$nanme_project = trim(strip_tags( $attachment->post_title )); | |
$year_proyect = trim(strip_tags( $attachment->post_content)); | |
?> | |
<?php $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'full'); // returns an array ?> | |
<li> | |
<a href="<?php echo $image_attributes[0]; ?>" class="fancybox" rel="group"> | |
<?php echo wp_get_attachment_image($attachment->ID, 'sliderHome', false, $default_attr); ?> | |
</a> | |
<p class="caption"> | |
<?php echo $nanme_project ?><br/> | |
<?php echo $year_proyect; ?> | |
</p> | |
</li> | |
<?php } // End of foreach Loop?> | |
</ul> | |
</div> | |
<?php } //End of if loop ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment