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

Questions tagged [query]

A generic term referring to the process of retrieving information from a database.

0
votes
0answers
12 views

How to limit which information about a product is returned by wc_get_products (WooCommerce)?

My current code uses wc_get_products to return all published products that are instock: $wc_products = wc_get_products(array( 'status' => 'publish', 'stock_status' =...
0
votes
1answer
27 views

How to display liked posts of current user in wordpress?

Im using an ajax like dislike post system on my wordpress theme. When the user likes the post there are some post metas to update or to add like the following: if( $post_like == "like" ){ ...
0
votes
1answer
26 views

how to SELECT for the current post id?

i am trying to get and count the values of a meta key (rating) and then calculate the sum. but the following code get all of values in wp_commentmeta table but i want to get just for the current post. ...
0
votes
1answer
14 views

Delete all drafts?

This is a common query to delete all post revisions: DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a....
1
vote
2answers
125 views

If newest post of category is newest post in general, skip first post of category

currently I am working on some customized blog templating and was wondering if there is any way to find out if the newest post of a category is also the newest post of the whole blog, so I can skip ...
0
votes
1answer
11 views

getting the values of hidden inputs to use them in a php mysql query

Im trying to update a value in the database, to do this I pass the values of the input an ID to another hidden inputs and submit the form via jquery, the values are set in the hidden input (tested). ...
0
votes
0answers
13 views

How to do a sql like query on serialized data of user meta data

As long I don't need to do a query with the data of all users, storing data like the zip code or city in the meta data as an serialized object works fine. But now I have to do a lot of different ...
0
votes
0answers
16 views

Offset with ajax load more posts duplicates

I have a shortcode that gets posts. I am using the shortcode three times on the page. The first time I grab the first 6 posts, the second time I offset by 6 and grab the next 4 posts, the third time I ...
0
votes
1answer
8 views

I need query_posts() to order results first by a meta value and then by post ID

I've read all the WordPress docs that seem relevant, and I've read lots of posts here and on other sites to find an answer to this, but I still can't find a way to do this. I have a custom post type. ...
1
vote
1answer
19 views

How to orderby multiple meta fields with another meta query

I have a custom post type ”events” with meta fields ”startdate” and ”enddate”. Archive query already uses meta query to show only upcoming or ongoing events, but in addition I need to order by both ...
0
votes
1answer
12 views

Nested select statements not working

I have 2 tables I need to search. 1st table Name: Personnel Fields: id, lname, fname, department, extension 2nd table Name: department Fields: id, department The 2nd table has the full department ...
0
votes
0answers
17 views

How to query the “standard” post format with the REST API?

I'm trying to write a search filter where it filters by author, category, and post format. I have successfully been able to filter by audio and video but am at a loss for the standard post format. ...
1
vote
1answer
43 views

hook to get (and change) the search string before processing

I'm trying to intercept the search query before it's executed in Wordpress. I've tried a bunch of things but it's just not working. So, for example, a user enters the search term RED SHOES. I want ...
1
vote
2answers
41 views

Modals using loops and ACF [on hold]

I am trying to make a page that queries every post of a specific category ("attractions"). I have been able to get the posts successfully, I just need to make the modals work. I have made a button ...
0
votes
1answer
18 views

WP_Query & Duplicate entries

I am currently using this code in order to get the latest three posts of my website, successfully and with no issues: $posts = get_posts( array( 'numberposts' => 3 ) ); but I want to switch to ...
0
votes
1answer
15 views

Shortcode to pull posts

I need some help please. I have created a shortcode to pull in posts, then using ajax it loads more posts. I have everything working but it is duplicating the first group of posts. below is my code. ...
0
votes
1answer
31 views

Any possible way to make $wpdb->get_results() return anything else than array?

So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I ...
0
votes
0answers
16 views

My archives page won't sort posts by month

I'm trying to make my own theme and I've created an archive template that works fairly well. The template shows all posts, but the problem is that all posts will show if I go to /2018/11/ (posts were ...
0
votes
1answer
20 views

Pass array of taxonomy terms to wp_query

I am trying to compile an array of taxonomies and terms to pass to wp_query, my array looks like this... Array ( [0] => Array ( [taxonomy] => color [field] =&...
0
votes
1answer
30 views

How to export current year posts from Wordpress?

I have very big Wordpress database, in which I am storing the records from year(2013) and now I want to export only current year(2018) posts from the database and also want to import it into staging ...
0
votes
0answers
17 views

Counting views looks like to count double

Within a shortcode I like to count my page views. Every time when i count a view with a custom field, it counts for 2 instead of 1. Does someone has any idea what could be the reason and how to solve ...
0
votes
2answers
27 views

How to read the value of a WordPress $query associative array (hash) key

New to WordPress programming (coming from a more conventional environment) and trying to understand some of its "unique" qualities. There is a directory page on our website and this code resides, ...
0
votes
0answers
31 views

Is there any way to get all custom posts and all custom terms with it's meta in few queries?

I'm developing a website with a record for me query count. It has 720 Query for the main page. I want to reduce it. The main page structure is like this: ~10 Custom Taxonomy Term Each Term has a ...
0
votes
0answers
13 views

Query Custom Post Type by Custom Field ID

I'm not sure if i've just been staring at this too long. To give some general info, I am trying to query custom post types based off another CPT's custom fields. Let me explain. I have a custom post ...
0
votes
1answer
17 views

How to query 5 users in random who have published more than 10 posts

I want to display 5 users who have published more than 10 posts, when the page loaded again, it should show another 5 users or mixed with new users with more than 10 posts. How do I achieve this? ...
0
votes
1answer
28 views

How to query users by post count no less than 10

I want to display 5 users by random who have published more than 10 posts but is not working. What I've done so far is $args = array( 'number' => 5 , 'meta_key' => 'post_count',...
0
votes
2answers
27 views

is_category in pre_get_posts results in php notices

I'm trying to set posts_per_page depending on what category is being shown. The following code works. function category_posts_per_page( $query ) { if ( $query->is_main_query() && $...
0
votes
1answer
24 views

Displaying posts on a page that have been assigned a value in a database

I have a wordpress site with a bunch of posts that I need to display on a page, depending on their value in a database. To be more specific, out of 20 posts I would only want to display the posts on ...
0
votes
0answers
18 views

WP Menu and pages can't load when $query->query_vars['meta_key'] is set

I'm having an issue similar to the one described in this post: Wordpress Menu Disappears when $query->query_vars['meta_key'] is set I have a WordPress site designed to hold listings for ...
0
votes
0answers
66 views

WP Query. Ordering posts by another post types meta

I have a custom post type called BID which contains a users bid (similar to freelancer.com, upwork, etc) However I need the BID results on the page to be ordered by meta stored in a users profile, ...
0
votes
0answers
16 views

Hide products with a certain tag from shop/homepage

for our ecommerce webshop we would like to exclude certain tags from the home page (shop) and the shop page. The tags should be visible on all archive and category pages. In another article I found ...
0
votes
0answers
29 views

Wordpress Query to show children of the current post using Elementor to design the page

I am trying to create a custom query to show the children of the current post. I am use the custom post type "services" and using Elementor as the theme builder. Elementor requires the query to be ...
0
votes
0answers
10 views

Request filter query variables different on sites within multisite

I have a multisite setup, and I used the request filter from the Wordpress API (https://codex.wordpress.org/Plugin_API/Filter_Reference/request) to try to alter a query before a page load, and I took ...
0
votes
0answers
24 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
1answer
17 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
0answers
12 views

Newspaper theme and WordPress naming: if (have_posts())… but where the query filters are written?

I'm working on a theme (Newspaper) and I've started customizing the category.php page and the myloop.php Coming from the c# style of programming for me is really hard to get the WP coding style. I'...
0
votes
0answers
17 views

Creating a downloadable goods website

Hi guys hope you're doing well, Today i have a question about organizing downloadable content on WordPress Website. So the idea is that i will be uploading huge data on my wordpress website to allow ...
0
votes
0answers
43 views

How do I use AJAX Query in my posts loop?

I have this function in my functions.php. All the AJAX and Query is working but displays the results of the loop right below the AJAX filter. I want the query loop to display in my main theme's ...
0
votes
1answer
18 views

How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta

I hope I can explain this without being too confusing. I have a site where I have a custom post type that has two custom hierarchical taxonomies ( categories ) and each post also has a meta filed ...
0
votes
0answers
26 views

WordPress WP_User_Query fail on large number of users available in database

We have an issue with WP_User_Query with huge database. Let me explain it. We have 147000 users with role "professional" under a category doctors in our database and when we apply search on database ...
0
votes
0answers
13 views

Need to make two dependent selects with dynamic content

I have two select dropdowns, one of them for device type(smartphones,cameras,PC etc), second are models for every device. The first select(Device) will be disabled for selecting, so if nothing is ...
0
votes
0answers
24 views

Wordpress query returns only old posts?

My website features several thousand posts. In a custom page template I run a post query, narrowing down results based on ACF fields within each post. When results are returned, only the oldest 100 ...
0
votes
0answers
11 views

Custom ordering a list of multiple post types

I'd like to create a (masonry grid style) list of multiple "custom post types". Just like a Pinterest. This can easily done with "Query Wrangler". Is there a way to create a custom ordering for this ...
-1
votes
1answer
37 views

Query Concatenation

I can't figure out how to properly concatenate my PHP variables in my MySQL query. $convert_class_id and $convert_char_id are holding numerical values. When I try to activate my plugin I get an ...
2
votes
2answers
68 views

Query all posts and not repeat the same tag

I need a query to show all posts in the site but not repeat the ones with same tag, I mean only show one post with the same tag. My current query is <?php $paged = (get_query_var('...
0
votes
1answer
44 views

Custom Query: If One Post Object Field Value Is The Same As Another

Is it possible to construct If/Else queries that look to see if two (or more) Post Object fields are the same – i.e. echo X if Post Object field 1 'value' is the same as Post Object field 2, else echo ...
1
vote
1answer
134 views

How to filter custom taxonomy categories on archive?

I'm trying to modify my archive.php where I can select the categories and filter their records. I can display the categories, detect if is a taxonomy page, but by selecting them, they are not ...
0
votes
1answer
30 views

PHP -> SQL Query with Summing

So I'm trying to display the sum of Paid Transactions for a customer's account: SELECT SUM(`payment_amount`) FROM `wp_gf_entry` WHERE `created_by` = '2' AND `form_id` = '37' AND `payment_status` =...
0
votes
1answer
26 views

How to hide posts of a specific custom category in Wordpress?

I have 2 custom post types on Wordpress website - Location and Event. Location is connected with Event as meta data (for sorting). For example: some event (Event post type) is taking place in London (...
1
vote
2answers
23 views

Specific query for custom post type

I am creating a directory and have a custom post type called "listings". I want to display a grid of "Most viewed" listings as well as "Highest rated" listings on my homepage and throughout the ...