Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to WordPress which allows users to query the posts database using a number of criteria. 2) $wp_query is the global variable that holds the main query object prepared by WordPress based on given request.

0
votes
1answer
13 views

get_posts custom field

This is a silly question, but I can't find the proper way to ask it to google. so, sorry if this is a repetitive question. I give a custom field with a checked that the user can check if he want ...
0
votes
0answers
27 views

meta_query works locally but not on live server

I'm filtering posts by author's last name initials. On my local server, the query runs beautifully, but when I push live, it doesn't. It doesn't find anything. Does it have anything to do with the way ...
1
vote
1answer
9 views

Use wp_get_recent_posts with search term

I have a function that uses wp_get_recent_posts() I need to use this same function on my search page but am having problems adding the search parameter to the $args array. Does anyone know if this ...
0
votes
0answers
19 views

How can I get date range of Events even if not exists?

I am building a Tribe Event Calendar custom Carousel query (wP_Query) in Wordpress using a custom query. I have the events query working great, but I want to display even the empty dates that have no ...
0
votes
0answers
19 views

WP_Query based on 's' and tax_queries

I have a search form for CPT. Basically search use 's' parameter of WP_Query args. $args['s'] = $search_title; It works pretty nice, but I need to extend search results by searching in taxonomies ...
1
vote
0answers
15 views

WP Query Args - Title or Taxonomy Value

How do I query by tax_value or title? I have $args = array( '_meta_or_title' => sanitize_text_field(preg_replace('/%20/', '+', $query[1])), 'posts_per_page' => 100, 'post_type' =&...
-1
votes
0answers
14 views

How to remove duplicate queries? [closed]

When i am using Query monitor plugin i am seeing duplicate queries it is saying that these are the potential troublemakers get_header() 1 call WP_Nav_Menu_Widget->widget() 1 call What process ...
1
vote
1answer
17 views

How to run query inside a class with namespace?

I tried to run a query inside a class this was the structure namespace NCK{ class Runquery{ public function execute(){ $query= new WP_Query(array(..............)); ...
0
votes
1answer
22 views

How to display author meta and count numbers for each user in comment.php?

All users are registered to comment on the site, so what I want to achieve is, to display user details like the meta info, description, url, etc... So, if possible also the number of posts and ...
0
votes
0answers
5 views

Add to search posts query array with post IDS which will appear first

Is there a way to add array of post IDS to set posts to be on top of search results? Something like adding a param top_post_ids inside the search hool: $query->set( 'top_post_ids', [45, 78, 94 ] )...
0
votes
1answer
17 views

How to mix two orderby-parameters into one ordered result

I'm trying to figure out how to get an alphabetically ordered list of posts using two different orderby parameters. Im filtering the archive query something like this: function ...
0
votes
1answer
20 views

Need Sub-category with main Category

Currently I used the following codes for get WooCommerce product categories. But, I need sub-categories too. Also what is the way to remove class="label-0" from select options? <?php if(...
0
votes
0answers
10 views

Trying to get posts in a sub-subcategory of custom taxonomy

I have a custom taxonomy, which is structured like Cars --Ford --VW Trucks --Ford --Dodge And then I have posts in this post type such as "Beetle" and "Jetta" assigned to the "VW" subcategory and "...
0
votes
1answer
28 views

using custom meta user data to run queries in WordPress

I have added custom user meta data to the WordPress user profile below is the code I used to add this data. This part of the code seems to be working fine and I do not have a problem with it. <?...
0
votes
0answers
16 views

How to search by title or tags exclusively?

I would like to modify the default search query of Wordpress to be able to get results from searching exclusively by tags or title. Meaning, it would show posts that contains a match from either the ...
0
votes
1answer
33 views

Get every post with value in meta key

I am trying to get every post, that has a specific URL in the meta key _cornerstone_data. From the WordPress documentary I was able to build this query, that probably gets me close to what I'm trying ...
0
votes
1answer
12 views

Can't reset the secondary query by wp_reset_postdata()

In custom post meta I have executed a custom query to get custom meta but when I tried to return to the main $post query, its printing the secondary loop.Where is my custom query and I have reset it ...
0
votes
0answers
8 views

get video poster image by video id

Using wp_query i got list of videos. All videos have their own poster images. How to get them? To make sure video exists i tried function wp_get_attachment_url and i got video url and its correct. ...
0
votes
0answers
20 views

How to use two query result together in one loop

I have posts with two different design in a loop, i doesn't known how to show that. I use a checkbox ( 'meta_key' => 'nabro_post_photo' ) for a posts have different design to will specify.I create to ...
0
votes
0answers
17 views

Custom Post Type WP_Query with filters and search

I have a custom post type called "doctor", this is the query I have set for displaying all the posts in the archive template: $args = array( 'post_type' => 'doctor', 'orderby' =...
0
votes
0answers
19 views

WP_Query Order by array specific post ids

I used post__in key to get posts from the specific post ids and order order posts by the other array specific post ids. I have following: $post_ids=array(100,200,300,400,500,600,700,800,900,1000); $...
0
votes
1answer
21 views

Meta query not showing result properly

In wordpress posts I have custom meta fields (ship from, margin price). I want to filter post by these meta fields. Ship from fields contains multiple value (Example: A product can be ship from china ...
0
votes
1answer
15 views

CPT category post/content is not showing on my page, Please review my coede

<?php $args = array( //'posts_per_page' => 99, 'post_type' => 'course', 'category_name' => 'Consectetur adipiscing elit sed do eiusmod', //<-- custom post type category name, I ...
0
votes
2answers
23 views

Limit home post to 10 without creating pagination?

I'm trying to display the last 10 posts only on the home without wp creating /page/2, /page/3, archives. I've been testing and it seems if you disable pagination it will just grab everything crashing ...
0
votes
0answers
13 views

Restricting Fields in wp_get_recent_posts

Looking at the function, there is no way to successfully restrict the fields in wp_get_recent_posts, is the only solution to write a WP_Query from scratch for a plugin? Im requesting a lot of ...
0
votes
0answers
19 views

Look for string in posts and postmeta

I have a query that finds the usage of an attachment in any post. $used_in_content = array(); foreach ( $attachment_urls as $attachment_url ) { $content_query = new WP_Query( array( 's' ...
1
vote
0answers
21 views

Query Multiple Custom Posts by Custom Fields

We have 3 custom post types and we need to query all 3 and join them in order the get that data to build up a complete list of films at a venue. Tables are as follows, with there unique ID's. The ...
0
votes
2answers
30 views

Is 'no_found_rows' a silver bullet for WP_Query optimization when getting all posts of a certain type?

I'm running a query (200-300 posts), while this might not be for a lot of people / hosts, I just want to optimize wherever I can, given the fact that a lot of things happen when running that ...
0
votes
1answer
14 views

Using get_posts to get posts based on a checkbox value with Advanced Custom Fields

I have a custom post type, "Jobs". These jobs have an ACF checkbox field, "city". "Jobs" can have more than one "city," so the jobs returned have meta values look something like this: [city] => ...
0
votes
1answer
21 views

Proper way to display latest 5 posts grouped by post type?

i need to display the latest 5 posts of each post type, something like: Latest BMW Posts: Post title BMW 1 Post title BMW 2 Latest Audi Posts: Post title Audi 1 Post title Audi 2 And so on. It ...
-1
votes
0answers
18 views

Pagination doesn't work after filtering by form

Is it possible to have this filtering method with working pagination? https://www.youtube.com/watch?v=UBhzNpQ6SqQ It was asked from the author 9 months ago, but he hasn't answered. I tried many ...
0
votes
0answers
43 views

Multi-Dimensional Array Get Column

At the moment the query below does what it should, queries a questions table for a series of questions and the looks for the corresponding answers from another table depending on a submissions id. It ...
0
votes
0answers
18 views

Create dynamic xml feed/link

A friend has asked me to help out on their wordpress site. They run a travel business site, and want to promote their tours on other sites. These sites have asked for a specific format of the tours in ...
0
votes
2answers
18 views

Setting proper query for multiple custom admin filters

I am adding custom admin filters for my custom post types. I am a bit confused about how to go with the parse_query filter in order to have my posts filtered based on 2 or more filters. Initially for ...
0
votes
2answers
19 views

Combine multiple queries, array_unique returns nothing

I'm combining multiple queries for a loop using the following method: function order_by_date( $a, $b ) { return strcmp( $b->post_date, $a->post_date ); } // get the posts for the first ...
-1
votes
0answers
12 views

Unable to make my website live on www.website.org after completing the website on www.website.org/wp

I had completed a wordpress Website in a www.Website.org/wp within the File manager. After completing the website, i wanted to make it live on www.website.org I was advised to move all the files from ...
0
votes
0answers
16 views

Combine WordPress Popular Posts plugin with WP_Query()

I would like to put this function wpp_get_mostpopular("range=weekly&order_by=comments") into my code, here's the example: <?php $albumquery2 = new WP_Query( array( 'category__in' =>...
0
votes
1answer
52 views

How to add 2 posts under another post? Formatting should be intact

The goal is to print 2 articles under an article IF the article is 200 words or less. I've had some help over at WordPress, but the code a couple of helpful people provided I can't integrate into a ...
0
votes
1answer
90 views

Meta Query Array Error 500

I have two CPTs – Match and Player. Each Match post entry contains details relating to a specific match (who played, scorers, etc.). This info is inputted via ACF Post Object fields corresponding with ...
0
votes
0answers
28 views

How to use WP_Query with Co Authors Plus

I have a site which have some authors who are normal WordPress users, but also some are using the Co Authors Plug plugin. When I make a WP_Query like this, it only returns results for the WordPress ...
1
vote
0answers
20 views

How to show recent and upcoming birthdays using meta_query

I have a date of birth user field, I am trying to show recent (past 7 days) and upcoming (next 7 days) birthdays. I have the below but it is not working because the years in the date of births are ...
0
votes
1answer
16 views

WP_Query order by two values

m trying to make WP_Query to order by two different values, but i cant figure how to do this. Im trying to get events in one query by ending time. There is custom ending_date_time field in every event ...
1
vote
1answer
16 views

When variable value have space between word, doesnt show any result WP_Query

I now create a widget, that return the post has same tag enter in inputbox I use WP_Query, but i have a problem. when i enter word with space in inputbox dont return any result, but when enter word ...
0
votes
1answer
20 views

How to store queried custom data and use it in multiple pages?

<?php $contact = new WP_Query(array( 'post_type' => 'contact' // 'post_status' => 'publish' )); ...
0
votes
1answer
33 views

wp_query posts with custom fields number smaller than

Posts have a custom field with key time and a value. In a template I want to query the posts that have the time key and a value smaller than 30. Whatever I have done so far didn't work. Below is the ...
1
vote
2answers
19 views

Is there a way to work with a specific the_field from an already queried post? [closed]

I'm relatively new to working with wordpress and php in general, so I'd like to know if someone can help me with this. I have a custom query that looks like this <?php $args = ...
0
votes
1answer
46 views

Custom wp-query in wordpress rest api

For example I have a query with tax and metas and other stuff.. how I can pass it to the rest api so i can call all the data with one call for example this function function load_special_args() { ...
1
vote
1answer
21 views

What's the WP way to load remaining custom posts?

I am displaying custom post types, grouped under their custom taxonomies (basically used @ChipBennett's answer from here: Display all posts in a custom post type, grouped by a custom taxonomy) for a ...
0
votes
1answer
18 views

show loop id post , only first id can read

I have a script , show post by id , and id post from array here my code : if ( have_posts() ) : while ( have_posts() ) : the_post(); $f = cherry_get_option('blog-featured-post',false); foreach ($f ...
0
votes
1answer
73 views

How to get post ID in a Page?

I'm trying to list all of my posts in a page(with post's content). Everything is showing correctly but the audio player which uses post id to get the URL of an attachment in the post is not showing. I'...