Image Gallery – Custom Order
-
We are using an image gallery field which has the option to sort the images into a custom order but cannot see how to output this same order within our custom template.
We are using get_posts to retrieve these images using custom $args, as this example which is currently sorting the attachments by title and ASC.
$args = array(
'order' => 'ASC',
'orderby' => 'title',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null,
'exclude' => get_post_thumbnail_id(),
'numberposts' => -1,
);The questions is how do we sort using the custom order from within the modified post ?
Thank you
-
Hi @bwdgroup
Since you are using your own query you’ll need to apply the order manually.
See WordPress documentation: https://developer.ww.wp.xz.cn/reference/classes/wp_query/#order-orderby-parameters
Cheers, Jory
Thanks Joey, PODS must store a value in the database to save the custom ordering positions ? we are fine with building the custom query but we need to know which parameters to use.
This has been resolved using the foreach loop if anyone requires it.
$gallery = get_post_meta( $post->ID, 'images' ); foreach ( $gallery as $image ) { echo '<a data-fancybox="gallery" href="' . pods_image_url( $image, $size = 'full', $default = 0, $force = false ) . '"><img src="' . pods_image_url( $image, $size = 'medium', $default = 0, $force = false ) . '"></a>'; }Hi @bwdgroup
I see you’ve found a correct solution 🙂 Metadata will run through Pods and apply it’s sorting.
Cheers, Jory
The topic ‘Image Gallery – Custom Order’ is closed to new replies.