Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

get_post_gallery in slider and joining gallery with content

$
0
0

Replies: 0

Hello so here is what I want. In the back-end of WordPress I sometimes like to create a gallery on pages or posts. So rather than displaying them as WordPress usually does (3-columns) I would like to use a bootstrap carousel to show them every time there is a gallery on the post. There is also a problem rather than showing all picture, it just shows the first one from the gallery, and I just tried several times playing with php etc and I still can not make it show me the second picture, or the rest if there are more.

This is my code for the slider(is already inside the while):


<!-- Carousel -->
<?php
if ( get_post_gallery() ) : $gallery = get_post_gallery( get_the_ID(), false ); ?>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php
echo "<li data-target='#carousel-example-generic' data-slide-to='0'></li>";
echo "<li data-target='#carousel-example-generic' data-slide-to='1'></li>";
echo "<li data-target='#carousel-example-generic' data-slide-to='2'></li>";
?>
</ol>
<?php foreach( $gallery['src'] as $src ) : ?>
  	<?php echo "<div class='carousel-inner' role='listbox'>" ?>
    <?php echo "<div class='item active'>" ?>
    <img src="<?php echo $src; ?>" class='' alt='image 1' />
    <?php echo "</div>" ?>
    <?php echo "<div class='item'>" ?>
	<img src="<?php echo $src; ?>" class='' alt='image 2' />
    <?php echo "</div>" ?>
	<?php echo "</div>"  ?>
<?php endforeach; ?>
<?php echo "<a class='left carousel-control' href='#carousel-example-generic' role='button' data-slide='prev'><span class='glyphicon glyphicon-chevron-left' aria-hidden='true'></span><span class='sr-only'>Previous</span></a>" ?>
<?php echo "<a class='right carousel-control' href='#carousel-example-generic' role='button' data-slide='next'><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span><span class='sr-only'>Next</span></a>" ?>
</div>
<?php endif; ?>
<!-- /Carousel -->

I would like to ask for somthing else as well. Once the slider works as Im expecting, how would I make the post to show the gallery pictures just in the slider; it currently shows them in the slider and in the content of the post, and I dont want that. :/

Sorry if I did not explain myself well, but English is not my native language.

Thanks,
Kevin.


Viewing all articles
Browse latest Browse all 59525

Trending Articles