New answers tagged

0 votes

Custom post type loop with custom category filtering

This solution worked for me 'project-type' => 'ABC'
user avatar
  • 101
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'...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 52.4k
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'][] =...
user avatar
  • 1
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 ...
user avatar
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
user avatar
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 ...
user avatar
  • 198
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 ...
user avatar
  • 11
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.
user avatar
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->...
user avatar
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 ...
user avatar

Top 50 recent answers are included