Home Forums Add-ons Repeater Field Single taxonomy pages, sorted by Repeater/Post Object


Single taxonomy pages, sorted by Repeater/Post Object

  • I’m hoping someone can help me with this as I have been unable to figure it out.

    I have a custom post type (Weddings) that is output on multiple pages via a repeater field with post object as client is nit picky about sorting each event. The issue is the posts within Weddings (broken down by multiple taxonomies) also needs the Prev/Next posts to sort within that order when on the single-weddings.php file. I’ve already gotten it to do the Prev/Next within the individual taxonomy however I’m unable to figure out how to break it down further so it matches the identical sort-order for the repeater field.

    So as an example: Weddings (Post Type) -> “Classic” (Taxonomy). When clicking on say “Adam & Eve” on the display output, the next one on the list should be “Bob & Brenda” as it’s in the #2 position on the repeater fields so in theory clicking “Next Post” should bring you to position #2, instead it’s calling say “Sophie & Mark” which is in position #14 as the single file is sorting based on inputting, and not the repeater field.

    So without having to setup the entire site on just a carousel (as it’s graphics intensive) is there a way to code the taxonomy/single file so that for these specific taxonomies it sorts by the repeater ID#s instead of the custom posts?

    So: Field #2 = current, previous = field #1 next = field #3.

    Is this even remotely possible?

  • Is every post represented in the repeater?

    You could create pre_get_posts filter in WP In this filter loop through the repeater, get all the post ID’s in the order that they should be displayed. Then alter the query to main query to include the ‘post__in’ argument with the array of post IDs and set the orderby argument to ‘post__in’.

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

You must be logged in to reply to this topic.