Timeline for Strange results from WP_Query
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 23, 2019 at 0:49 | comment | added | Sandbox Wizard | Ah, okay. I hadn't thought about it that way. Thanks I'll look at that. | |
Feb 23, 2019 at 0:29 | comment | added | Tom J Nowell♦ | They're usually used to group things together, but that's just one way of viewing it. Think of it instead as filtering out other things. E.g. a category lets you find all posts that have X, which is what you're doing in your post meta query. So why not do the same with fee codes? There's no harm in having just 1 post in each term. Post meta tables are optimised for finding values when you already know the attached post ID. Taxonomies are optimised for finding post IDs when you already know the value | |
Feb 22, 2019 at 23:42 | comment | added | Sandbox Wizard |
@TomJNowell I have a custom post type for fees , each fee has its own fee_code would it make sense to use a custom taxonomy for the fee_code ? My understanding of taxonomies was that they are used to group objects together. There is no overlap between fee_codes, it would be a 1 to 1 relationship.
|
|
Feb 22, 2019 at 22:35 | history | edited | Sandbox Wizard | CC BY-SA 4.0 |
Added another set query parameters I tried
|
Feb 22, 2019 at 22:30 | comment | added | Sandbox Wizard |
I'm using $the_query->request to see the query that was used and am looking at $the_query->posts to see what has been returned. I don't have any filters on pre_get_posts . I'll look into using custom taxonomies, but this process is for updating fee values and is used once a year, so I'm not too worried about performance for the time being.
|
|
Feb 22, 2019 at 21:38 | comment | added | Tom J Nowell♦ |
What does the code that tests this query object look like? Keep in mind that WP_Query doesn't generate a query, it generates multiple queries. Also, you never mentioned if you have filters on pre_get_posts , or where the $postmeta array comes from. I would also keep in mind that looking for posts via their post meta can be extremely expensive/slow/taxing on a server, that's what taxonomies were added for, is there a particular reason you didn't use a custom tax named fee_codes ? It would've been potentially 100-1000x faster, easier to write queries for, and given you free templates/urls
|
|
Feb 22, 2019 at 20:33 | history | edited | Sandbox Wizard | CC BY-SA 4.0 |
Changed `numberposts` to `posts_per_page` as per @Mike
|
Feb 22, 2019 at 20:01 | answer | added | MikeNGarrett | timeline score: 0 | |
Feb 22, 2019 at 19:50 | history | asked | Sandbox Wizard | CC BY-SA 4.0 |