Skip to main content
7 events
when toggle format what by license comment
Dec 13, 2017 at 23:50 comment added Tom J Nowell I'm saying when WP gets a post from the DB it shows some initiative and fetches all the post meta for that post in advance so it doesn't have to make lots of small DB queries. As for code I'm a firm believer that if you don't understand it in plain english then copypasta will do no good. For each post, grab the meta, and check if it's lower than the lowest, or higher than the highest, and keep track of the highest you've seen and the lowest you've seen., a for loop with 2 if statements inside
Dec 13, 2017 at 21:10 comment added Benjamin Are you saying calling get_post_meta for each post is faster than my query, don't think I understand your approach. A bit of code would really help make this more clear.
Dec 13, 2017 at 2:37 comment added Tom J Nowell You'd fetch all the post meta for the posts you want to test, then manually check the lowest and highest values. Think of it the same way as if someone gave you 12 books full of numbers and asked you to find the lowest and the highest, you'd open each book starting from the first page and going to the last page reading each number, and if the number is the highest of the lowest, you'd write it down as the new lowest, or the new highest. It's the same, but in PHP
Dec 12, 2017 at 22:18 comment added Benjamin The first part about the quotes makes sense I was referring to the second part of your answer that mentioned the speed increase using a different technique then what I am using
Dec 12, 2017 at 14:27 comment added Tom J Nowell @George you put quotes around your placeholders, e.g. \'%3$s\' versus %3$s. The docs explicitly say not to do this
Dec 12, 2017 at 4:43 comment added Benjamin Tom - Can you provide some code to make what your saying more clear, not sure I understand. My code finds all available filtered posts within a range of min/max values based off the meta key, price in this case. The $include var holds the post ids I want to limit my query too.
Dec 12, 2017 at 2:53 history answered Tom J Nowell CC BY-SA 3.0