• Resolved bwdgroup

    (@bwdgroup)


    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @bwdgroup

    Since you are using your own query you’ll need to apply the order manually.

    See WordPress documentation: https://developer.www.ads-software.com/reference/classes/wp_query/#order-orderby-parameters

    Cheers, Jory

    Thread Starter bwdgroup

    (@bwdgroup)

    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.

    Thread Starter bwdgroup

    (@bwdgroup)

    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>';
    }
    
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @bwdgroup

    I see you’ve found a correct solution ?? Metadata will run through Pods and apply it’s sorting.

    Cheers, Jory

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Image Gallery – Custom Order’ is closed to new replies.