Questions tagged [query]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
14 views

Arrange results

I'm trying to get a list of Estados (states) from a Pais (country) selected by the user. First I retrieve the list of the countries, then I call the child, being the states of that selected country. ...
-1
votes
0answers
11 views

Can we use WC_Products_Query to get products that matches a desired product name? [on hold]

I have a requirement such that: User searches for a product Any product name that has a match for at least one word of the search string must be returned It must be in the descending order, with the ...
0
votes
0answers
25 views

WP_Query for custom taxonomies showing posts from non-specified terms?

I have two custom taxonomies "products" & "products-info" registered for custom post type "products-posts". There are three terms (shoes, shirts, pants) in "products". Similarly, there are two ...
0
votes
0answers
7 views

Adding products to cart is successfull but upon clicking cart it shows empty. and this is happening intermittently

I am a running a website shorthairbigteeth.com It is hosted on godaddy.in. I have been getting this empty cart issue for 1 month now. The customer adds the product to cart and it shows the icon of ...
0
votes
0answers
22 views

How can I do a search by title and content in separate fields

this is my query, It works well. $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'cat'=> $category, 'date_query' => ...
2
votes
2answers
109 views

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

I have this code: $query = "SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id ...
0
votes
1answer
34 views

Orderby event date (if it exists) or post date (if it doesn't) - how to reorder posts based on meta value OR date

I need a way to sort the posts on my tag and category archives according to the event date (if it exists) OR post date (if it doesn't). I have a combined archive for events and posts, but want to ...
0
votes
0answers
22 views

meta query OR and AND

My dev is away and this code works $args = array( 'post_type' => 'page', 'posts_per_page' => 4, 'meta_key' => 'r_overall_score', 'orderby' => 'meta_value_num', ...
0
votes
0answers
16 views

Need to display a Jan 1st post as the site's front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc

slightly unusual client request. I'm using Divi and I have a nice Divi layout created for a video and text post which is ready to go. The client wants to create 365 posts (one for each day of the year ...
0
votes
0answers
14 views

Query Multiple meta key values

I have a custom post type with 4 custom fields Participant (ayp_user) Event (ayp_event) Category (ayp_category) Total Score (ayp_score) I have set the following meta_query in a query. But it is ...
0
votes
1answer
17 views

How can i limit the number of posts to the most recent 6 in my query?

I have a crashing jQuery slider that i have been asked to fix. Currently it is loading 128 slides (causing crashed of course), but we only want to see 6. I tried using jQuery to remove() 7th and ...
0
votes
0answers
32 views

SQL query conditional from 3 tables

I've trying to get a SUM() value, and the statment works fine in MySQL query but not Wordpress function. In SQL is this select sum(meta_value) from `wp_woocommerce_order_itemmeta`, `...
0
votes
1answer
58 views

WordPress add_query_arg from ajax and make url friendly

In WordPress I have set a query arg in ajax like this add_action( 'wp_ajax_get_prepare_link', 'prepare_link'); add_action( 'wp_ajax_nopriv_get_prepare_link', 'prepare_link'); function prepare_link()...
0
votes
0answers
36 views

Url parameter going to 404 not found

I am trying to get data from url query in my woocommerce website. But when I go to the link it redirects to 404 not found. If I remove the 'product' from the query and add something else it works fine....
0
votes
0answers
16 views

How can I show all posts, even ones that lack the given meta_key, when using orderby in WP_Query?

I have some businesses: +---------------+--------+ | business_name | rating | +---------------+--------+ | McDonald's | 3.9 | | Subway | 4.1 | | Pizza Hut | 4.3 | | TGI Friday'...
1
vote
0answers
47 views

Mysql + Wordpress is killing my server (huge CPU usage and getting slow) [closed]

I have recently installed wordpress in a production server with 80K fields in wp_users registered, 175K fields in wp_post table and 350K fields in wp_postmeta. Problem is that mysql database is ...
0
votes
1answer
14 views

How do I query with multiple custom fields orderby in same column?

I have a list of posts, one column of which I am trying to set in alphabetical order. The problem is that these posts have one of two different custom field value types shown in the same column. One ...
0
votes
1answer
11 views

How to add post type in masonry posts elementory widget

When I try to create a website using Wordpress 5.2.2. I found a widget called Masonry Posts in Elementor Panel. But when I added the widget and checked there is no option to choose the post type. We ...
0
votes
1answer
66 views

Display a post from custom post type only if all the selected taxonomies and custom field value matches the record

I have created a custom post type exam_result with academic_year as a custom taxonomy, school_class as a custom taxonomy and roll number as a custom filed using the Advance Custom Field plugin. The ...
0
votes
1answer
31 views

Query against multiple locations within single custom post type post

I have a custom post type for "Events" and each event can have a variable amount of "Locations" (lat/lng) which is stored as meta. I need to be able to get "Event" posts based on the bounds of a map. ...
0
votes
1answer
24 views

$wpdb insert is not work

I try different way for insert data in custom table but is not work and there are not errors. Sometimes is save, but most of the time is not. I check around the web, but no solution is working for ...
0
votes
0answers
38 views

WC Booking query bookings with date ranges

Using WooCommerce Bookings extension and the newly provided REST API I search a way to query bookings by date intervals. Is possible to achieve something like this?
0
votes
0answers
11 views

SQL to Query the db and return all posts and it's metas

I am trying to query the wp db and return all posts and it's metas. However, the return is very slow. Am I doing it the right way to get the most optimal results? Please see my SQL below: SELECT ...
0
votes
0answers
16 views

SQL query that returns a list of duplicate posts IDs, comparing their post_parent and a post meta value?

I want to build a SQL query that would fetch all the duplicate posts; by comparing their post_parent and the 'link_url' post meta. ID | post_parent | link_url meta 1 11 ...
0
votes
1answer
11 views

Restrict WordPress search to a single ACF field

I've used the following filter to include an ACF field into my search results. add_filter( 'pre_get_posts', 'so_9224493_adjust_search_query'); function so_9224493_adjust_search_query( $query ) { ...
0
votes
1answer
32 views

Why pagination is not working with tax_query param?

this is my query: $p_query = new WP_Query(array( 'post_type' => $post_type ,'post_status' => 'publish' ,'posts_per_page' => $per_page // 6 ,'paged' => $page // 2 ,'...
0
votes
1answer
25 views

Yoast primary category query modification

I have a problem with Yoast and displaying my primary category alongside rest of the posts from that category. Let's say I have 4 posts, all of them are lorem category and one post has set lorem as ...
0
votes
0answers
19 views

Remove post name of custom WP_Query when using in pagination?

Is this possible? I am trying to get pagination working on my pages and single pages. It seems like it's working, as it recognizes how many pages there are and shows the URL. The problem: the URL is ...
0
votes
1answer
22 views

Returning a custom content types with meta values

I find myself facing a situation where I will have a bunch of custom post types and I want to select those with specific meta values. There is a slight wrinkle in that the value I want to select ...
1
vote
3answers
41 views

List of the years with posts presented

I need to get a list of the years with posts of given category. Like this: 2008, 2009, 2010, 2012, 2013 (if there were no posts in 2011, it's not included). I try this query, and it works — I get my ...
0
votes
2answers
33 views

wp query multiple values > display a specific value first

I have a query that get relationship fields for multiple ID. I get the ID of selected item, and merge it in an array with other ID's ex : my page relationship ID = 5 my other pages ID in array = 6,...
0
votes
0answers
17 views

How to find duplicate posts?

The query below returns the second and subsequent post duplicates. Can someone better with SQL help me tweak the query to return all posts in a duplicate set? The reason is each duplicate set on my ...
0
votes
0answers
43 views

Slow page loads due to WordPress Core Query

I have a page with many posts and every single page load is noticably slow. Hence, I have checked with Query Monitor the culprit(s) for the slow loading time and found that one query in particular is ...
0
votes
0answers
13 views

wp query et author

I try to display at the end of an article a post-type list of the same author. I try with this code, it works perfectly on the author page but not on an article add_action( 'elementor/query/offres123'...
0
votes
0answers
24 views

Database Query not accepting my WHERE LIKE wildcard in my PHP code?

I have a query that works fine when I run it in PHPMyAdmin, but does not return anything when ran via the website form post. I copy and paste the exact SELECT below, replace both$searchByText and $...
0
votes
1answer
44 views

Custom query pagination with php parameter as arg problem

I have create a loop with a custom query. This query contains a php parameters that i m getting from url with GET method. The problem is that the pagination (even if it counts the posts correct at ...
0
votes
0answers
11 views

sql query page listing with option selected

I want to separate a page page from the sql query. for example current page and last page with option selected. my listing page code <ul class="list-group"> <h2 class="h3">...
0
votes
0answers
154 views

PHP Fatal error: Uncaught Error: Call to a member function insert() on null

Hi I have an error that it's: Call to a member function insert() on null that the function $wpdb->insert(); returns. Now, this is my array:  Array ( [title] => Huqvarna 610 cross blocco ...
0
votes
0answers
21 views

Getting custom field dynamically from variable

I feel like this should be relatively easy but for some reason I'm lost. I'm trying to access an associated posts ACF repeater field based on what row is being outputted. Here's the query in ...
2
votes
2answers
152 views

Query WooCommerce orders where meta data does not exist

I'm trying to fetch all my WooCommerce orders where some additional metadata is equal to not empty. $orders = wc_get_orders( array( 'orderby' => 'date', 'order' => 'DESC', '...
-1
votes
1answer
33 views

SQL Query : how copy all tags of post into their post content in wordpress by sql query

I want to copy/move all tags of a post into posts content, as text form not in a link form. For example: A post has: a title in title field, some content in content field (like: a ...
0
votes
1answer
32 views

Query where ANDing slug values not working

I realize this isn't the most elegant sql. I modified this query where the original query only selected from a single category (the slug field of the terms table). I am trying to obtain a result set ...
1
vote
1answer
85 views

Get stock by custom meta field on all Woocommerce variable products

In WooCommerce, I have a custom meta field "Brand" on my products, and each product is assigned with one of the Brands. Now I want to get total stock for each brand from all products and I have only ...
0
votes
2answers
17 views

correct validate and sql query

Is this method of operation on the database is safe and correct? if(isset($_POST['name'])){ $table = $wpdb->prefix.'_my_table'; $post = trim(sanitize_user($_POST['name'], true)); $...
1
vote
0answers
30 views

get search results from only specific page name in wordpress

I have created a page by using add_submenu_page: add_submenu_page( "pharma-plugin", // parent slug "All Trade Name", // page title "All Trade Name", // menu title "manage_options", // ...
0
votes
0answers
25 views

Create a custom table with column as an index

I want to create a table in my wordpress database with a column that is an index. But I can't seem to make it work with this code: $table_name_t2mtokens = $wpdb->prefix . "t2mtokens"; $...
0
votes
0answers
34 views

Duplicate posts when using pre_get_posts for author.php

I'm trying to change the main query into the author.php but there are some duplicate posts?! How can I fix it, Thank you! function change_author_query( $query ) { if ( $query->is_author() &...
0
votes
0answers
49 views

How do I search WordPress posts by categories and tags in addition to title and content?

I would like to expand my site's default search fields (title and content) to include categories and tags without installing a plugin. Including the below code in functions.php allows me to ...
0
votes
1answer
29 views

problem with sql query

I have a problem with quotes with query. My code: $this->table_name= 'table_name'; $how_much = $this->wpdb->get_var($this->wpdb->prepare("SELECT COUNT(*) FROM {$this->...
0
votes
1answer
32 views

correct sql query

I wrote database queries some time ago and now I would like to improve them. But something I do wrong and i need help. class tags{ private $wpdb; public function __construct(){ ...