New answers tagged wp-query
1
vote
Accepted
How WP determines archive page vs single page?
TL;DR:
WordPress uses URL query string variables to select a template based on the Template Hierarchy.
Generally, WordPress looks at the URL path, parses it into segments, rewrites the URL using ...
1
vote
WP Query filtering by custom category not showing all relevant posts
@jacob-peattie answered the question in his comment - I used the wrong key to set the number of posts my query generates. Swapping numberposts with posts_per_page solved the issue.
Here's the final ...
0
votes
Why is my nested 'OR' meta_query not working?
So when trying around I haven't gotten any further but maybe this is an even better example. This keeps returning NULL. On top of it all I need to clear all server cache every time because it stores ...
0
votes
Using $paged redirects /page/2 to page 1
I've tried best-noted workaround and it didn't worked for me - using /page-name/?page=2 still redirected me to /page-name/.
Also noticed using ?p=2 didn't work either.
The only workaround I found is ...
0
votes
Why is my nested 'OR' meta_query not working?
Just a couple of minor formatting changes: an extra nested array that can be deleted, and the incorrect 'value' when using the '=' compare operator, and an unnecessary 'relation' parameter.
$args['...
0
votes
Accepted
Removing filename searches when searching attachments
OK, my colleague has found the solution:
add_filter( 'pre_get_posts', function($wp_query) {
add_filter( 'wp_allow_query_attachment_by_filename', '__return_false', 999 );
}, 999);
Works ...
0
votes
Accepted
Check for a value in a custom query
After some serious thinking and some trial and error I came up with this solution.
Because all data in the query comes from ACF fields I found a way to use the data from these fields to get the result ...
1
vote
Removing filename searches when searching attachments
Approaching this from the SQL is a mistake, and instead a quick search of the official dev docs for filename reveals a filter named wp_allow_query_attachment_by_filename that is set to true by default:...
0
votes
Multiple meta value orderby clauses in a WP_Query
Try to name the two arrays you want to use for the orderby. Like this:
$args = array(
'meta_key' => 'campaign_end_date',
'orderby' => 'meta_value_num',
'order' => '...
Top 50 recent answers are included
Related Tags
wp-query × 5715custom-post-types × 874
loop × 725
meta-query × 484
posts × 463
query × 437
php × 401
custom-taxonomy × 387
query-posts × 368
custom-field × 365
pagination × 349
categories × 284
search × 223
order × 207
post-meta × 172
get-posts × 169
functions × 158
taxonomy × 156
ajax × 154
advanced-custom-fields × 154
pre-get-posts × 147
tax-query × 146
filters × 144
woocommerce-offtopic × 129
plugins × 121