Support

Account

Home Forums General Issues Custom post type navigation ordered by ACF date field Reply To: Custom post type navigation ordered by ACF date field

  • The functions you are using do not have filters that are easily usable. You would have to manipulate the actual SQL. They will always return something based on the WP post date.

    If you want this to work then you’d have to update the WP post date based on the ACF field value.

    If you don’t want to do that then you’d have to write your own queries.

    I would make the following suggestions.

    • limit the number of posts found to 1
    • for the meta value use the current posts acf field value
    • for the previous post us < for your compare and order DESC to get the post with the first date before
    • for the next post use > for your compare and order ASC to get the first post with the first date after

    You should also be limiting your queries for the first and last post to 1 as well, there is no need to get multiple posts when you only need 1.