Support

Account

Home Forums Add-ons Gallery Field attachment.php image navigation not following same order as ACF Gallery

Solved

attachment.php image navigation not following same order as ACF Gallery

  • Hey all,

    I have created my own photo gallery with the ACF Gallery Addon. When viewing images (in the file attachment.php) I have Next and Previous buttons to browse the rest of the ACF Gallery. This works fine, however when I start re-ordering the ACF Gallery, the order is not reflected in the Next/Previous buttons (I think the next/previous buttons are alphabetically ordered to the next image). Can anyone please suggest a solution? Thanks

    http://codex.wordpress.org/Function_Reference/next_image_link
    http://codex.wordpress.org/Function_Reference/previous_image_link

  • Update: The next_image_link and previous_image_link retrieve the neighbouring Post in the WP database. The next_image_link just looks for the next item in the database (which is usually based on upload date/time).

    It look’s like we may have to create a new function to solve this problem:

    Maybe an Array of ID’s for each ACF Gallery which can be navigated on the attachment.php?

    Any help greatly appreciated :D!!

  • Managed to find a solution by building my own functions, I will explain the fix below:

    The order of the ACF Gallery is stored in the SQL database table ‘wp_postmeta’, under the meta_value of (in my case) portfolio_gallery. There is an array of Image ID’s in the order you have saved them in. I had to gain access to this array, loop through the values, find the next and previous ID’s of the required images and output there URL’s via WP’s function get_permalink();

    I will post my final code when I’ve had time to neaten it up 🙂

    Hope this helps anyone else who finds them self in the same situation.

  • Hey yorkshiredev, can you post your solution please?

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘attachment.php image navigation not following same order as ACF Gallery’ is closed to new replies.