• I have a custom post type, let’s call it “Heroes”.
    I also have repeated custom sub fields in a repeater using “advanced custom fields” in these posts with numeric values.

    So I have “Post 1” that’s a post type “Heroes”. It has a custom sub field “life” repeated two times. The first input field of this repeater has the number 2, the second has the number 1. It also have a custom sub field titled “death” and it is repeated twice. The first with the number 6, and the second with the number 20.

    What I’m trying to do is query a list of all the posts where the post type is “Heroes” and where the equation ((sum of all custom sub fields “life” in post) * 50) – (sum of all custom sub field “death” in post) is greater than zero. I’m wanting the list of posts to only have the post title, a permalink to that post wrapped around the title, and the number that the equation equaled being greater than zero.

    So something like this..

    • “permalink” Title One “/permalink” – 124 Remaining
    • “permalink” Title Ten “/permalink” – 13 Remaining
    • “permalink” Title Twelve “/permalink” – 9 Remaining

    Where my example “Post 1” came out to ((2+1) * 50) – (20+6) which made 124, and because 124 is greater than zero it’s listed this post above as “Title One”.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Query Posts By Equation’ is closed to new replies.