New answers tagged wp-query
0
votes
Custom post type loop with custom category filtering
This solution worked for me 'project-type' => 'ABC'
1
vote
Custom post type loop with custom category filtering
Is that category or custom taxonomy?
if this is a category, then try this one.
<?php
$loop = new WP_Query(
array(
'post_type' => 'portfolio',
'posts_per_page' => 50,
'category__in'...
1
vote
Why isn't my `meta_query` array functioning properly?
I already got it. Was missing an extra array() in the meta_query.
My updated code is this:
I'd like to thank this website. Sometimes just posting the question helps me figure it out. What a cool ...
1
vote
Conditional operator OR not working with custom fields
The problem is that you used OR, specifically the human verbal colloquial understanding, not the logical definition. What you actually meant was AND.
Here's a table demonstrating what happens to A and ...
0
votes
WP_Query multiple value not working
This is waaaay after the fact, but maybe it'll help someone else. You're looking for an IN comparison here - where the value is IN a group of values.
Here's what it'd look like:
$args['meta_query'][] =...
1
vote
Accepted
complex get_posts() query to select child pages
You need a loop for this to handle the condition:
/** list for course and childless department pages */
$course_and_childless_department_pages = array();
/** get department pages */
$department_pages ...
0
votes
How to get all user posts from two post types in wp_query
problem solved!
The code works great,
The problem was that the "polylang" plugin filtered out undefined post typs.
When I turned off the plugin all the author's posts appeared
1
vote
Accepted
Reset postdata not working on WP_Query in functions.php
You don't need to modify the global current post, just use the get_posts() function instead of WP_Query().
function get_root_project_value( $meta_key ) {
if ( empty( $meta_key ) ){
return ...
0
votes
How to get all user posts from two post types in wp_query
Ye. It is possible with single query.
WordPress is allowed to fetch posts from different post type. For example, consider the default post types "post" and "page"
To fetch user ...
0
votes
How do I reset $wp_query in a function?
There's nothing to reset here. wp_reset_postdata() is only required if you're using $posts->the_post() or otherwise modifying the global $post variable.
0
votes
The Operator "NOT IN" Does Not Work In tax_query
Just to complement the answer by @nibnut, I recommend to check first if there is some tax_query in the Query, so you do not overwrite them:
$query->tax_query->queries = (array) $query->...
1
vote
Accepted
Display if author page is author page of current user
The is_author() conditional can be used to check if the query is targeting an author's page. By passing one or more User IDs/nicenames into it, it will check for specific author pages. So to check if ...
Top 50 recent answers are included
Related Tags
wp-query × 5573custom-post-types × 852
loop × 705
meta-query × 465
posts × 456
query × 434
php × 384
custom-taxonomy × 374
query-posts × 356
custom-field × 352
pagination × 347
categories × 274
search × 218
order × 200
post-meta × 169
get-posts × 164
functions × 158
taxonomy × 150
ajax × 148
tax-query × 144
pre-get-posts × 143
advanced-custom-fields × 141
filters × 138
woocommerce-offtopic × 129
plugins × 121