Support

Account

Home Forums ACF PRO Check for a value in a custom query Reply To: Check for a value in a custom query

  • What I gave you is the only way to do it. This is the only way to group posts by a custom field value.

    You need to look at the value of the field, you need to compare it with the value of the field on the previous post, if they do not match then you display a new heading.

    To summarize:

    • Set up a variable to store the last value shown
    • Loop over the posts
      • Compare the value of the current post with the last value shown
        • if the values are different
          • Show something based on the new value
          • update the last value show to the new value