148 posts
  • Czech Republic
  • Has been a member for 2-3 years
Itachicz says

Hi,

I have simple wordpress gallery in post and now I want to get images (url’s) from this gallery in my index.php.

Does anyone know how to do it? I searched all over the web, but nothing…

thx for your time.

707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
ChillThemes says
 <?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
 ?>

Or, not tested but should work.

<?php
    $gallery = do_shortcode( sprintf( '[gallery id="%1$s" columns="5" numberposts="16" orderby="rand"]', $post->post_parent ) );
    if ( !empty( $gallery ) )
        echo $gallery;
?>
http://codex.wordpress.org/Using_the_gallery_shortcode
148 posts
  • Czech Republic
  • Has been a member for 2-3 years
Itachicz says

 <?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
 ?>

Or, not tested but should work.

<?php
    $gallery = do_shortcode( sprintf( '[gallery id="%1$s" columns="5" numberposts="16" orderby="rand"]', $post->post_parent ) );
    if ( !empty( $gallery ) )
        echo $gallery;
?>
http://codex.wordpress.org/Using_the_gallery_shortcode

First of all thx for your post :)

yes this works for displaying styled gallery but I need images url, because I want use them in a slider :)

707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
ChillThemes says
3197 posts
  • Sold between 5 000 and 10 000 dollars
  • United States
  • Bought between 10 and 49 items
  • Has been a member for 4-5 years
  • Exclusive Author
organicbee says
<?php //Get the Image attachment stuff
$args = array(
        'post_type' => 'attachment',
        'numberposts' => null,
        'post_status' => null,
        'post_mime_type' => 'image',
        'order'          => 'ASC',
        'post_parent' => $post->ID,
        'posts_per_page'    => '9999'
    );

$attachments = get_posts( $args ); ?>

<!-- Start Post <?php the_ID(); ?> -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>    

     <?php if(count( $attachments ) > 1) { ?>

         <div class="flexslider">

            <ul class="slides">

            <?php foreach ( $attachments as $attachment ) {     

                $image_url =  wp_get_attachment_image_src($attachment->ID, 'cw-original' ); ?>

                <li>

                    <a href="<?php echo $image_url[0]; ?>" rel="prettyPhoto[pp_gal]"><?php echo wp_get_attachment_image( $attachment->ID, 'cw-gallery' ); ?></a>

                    <?php echo($attachment->post_excerpt);?>

                </li>

            <?php } ?>

            </ul>
        </div>
    <?php }//endif ?>
</article>

you still need to add the content etc… also remember that the gallery shortcode can still be inserted into post, you can strip them/hide but depending on if its for personal or a commercial theme thered be a different approach

148 posts
  • Czech Republic
  • Has been a member for 2-3 years
Itachicz says

OrganicBeeMedia

This function doesn’t work for me.. when I place it in to my loop, it displays nothing

thx for your time.

3197 posts
  • Sold between 5 000 and 10 000 dollars
  • United States
  • Bought between 10 and 49 items
  • Has been a member for 4-5 years
  • Exclusive Author
organicbee says

OrganicBeeMedia

This function doesn’t work for me.. when I place it in to my loop, it displays nothing

thx for your time.

thats because its trying to pull my custom image sizes you’ll need to change it to fit your needs

148 posts
  • Czech Republic
  • Has been a member for 2-3 years
Itachicz says


OrganicBeeMedia

This function doesn’t work for me.. when I place it in to my loop, it displays nothing

thx for your time.
thats because its trying to pull my custom image sizes you’ll need to change it to fit your needs

Even when I changed your image sizes to default values it doesn’t work…

by
by
by
by
by
by