Viewing 1 replies (of 1 total)
  • Plugin Author dinamiko

    (@dinamiko)

    Hi hagopi,

    I have an example of a basic gallery here:
    https://wp.dinamiko.com/demos/dkpdf/post-format-gallery-tiled/
    uses a shortcode gallery like this:
    [gallery type="rectangular" columns="4" ids="755,757,758,760,766,763" orderby="rand"]

    another way for getting all images of a post is using a custom function inside the template, more info on copy plugin templates in your theme:
    https://wp.dinamiko.com/demos/dkpdf/doc/how-to-use-dk-pdf-templates-in-your-theme/

    function for getting all images in a post:

    <?php
    function dinamiko_get_images( $exclude = FALSE, $limit = 8 ) {
    	global $post;
    	if($exclude == FALSE) {
    		$thumb_ID = '';
    	} else {
    		$thumb_ID = get_post_thumbnail_id( $post->ID );
    	}
    	return get_children( array('numberposts' => $limit, 'post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'exclude' => $thumb_ID) );
    }
    ?>

    then use a foreach loop for getting all images:

    <?php
    if ($images = dinamiko_get_images( TRUE ) ) {
    	foreach ($images as $image) {
    		$img = wp_get_attachment_image($image->ID, 'large'); ?>
    		<div>
    			<?php echo $img;?>
    		</div>
    	<?php }
    }
    ?>

    notice that in this case, we’re getting the Featured image too, using TRUE as function parameter.

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Gallery Images too’ is closed to new replies.