Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
22 views

Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query

Can it be done with pre_get_posts in functions.php file to change the output by get_posts queries on blog/site. I found nothing about adding html attribute to anchor tag here: https://developer....
0
votes
0answers
12 views

List all categories that have results in a query

I have an archive page that I am building multi-filtering for. The archive page lists paginated results from a custom post type, and there are 3000 posts within it. I would like to be able to filter ...
0
votes
0answers
9 views

Woocommerce Updating Order Status very slow?

I am trying to bulk update lots of Woocomerce orders (Approx 8000) from processing to Completed. Using the bulk editor I just get an error trying to select so many and change the status. So I made the ...
1
vote
0answers
10 views

Conditional query that displays on Woo product attribute pages

I have a custom query set up that currently modifies the product category pages of my website. I would also want this code to affect the product attribute archive pages of my website, but I am having ...
0
votes
0answers
18 views

Custom Query with Sticky Posts

I’m trying to write a custom query which filters by category and shows only a certain number of posts. So far that’s a simple thing along these lines: $args = array( 'showposts' => 1, 'cat' =>...
0
votes
1answer
30 views

How to search through “post title” and “tags” using WP_Query?

In my custom search form, i'm currently using these kind of $args with my WP Query: $args = array( 'post_type' => 'post', 'posts_per_page' => $postsPerPage, 'offset' =&...
0
votes
0answers
30 views

Get list of all existing meta keys [duplicate]

I'm using Custom Fields in my post type and I'm looking for a way to get a list of all existing meta keys. I know I can get all meta keys for a specific post with get_post_meta() but I need all ...
-1
votes
1answer
26 views

how to use transient method?

It was suggested to use a transient method to remove the duplicate queries Duplicate Queries Why does this don't work? Is it the wrong way to use it private function get_acf_list() { if(!...
0
votes
0answers
27 views

PHP Warning: mysqli_error(): Couldn't fetch mysqli in

I am new at this, so this is my case. I am getting this error on my Wordpress site and I need someone to point me out where to search the problem. I know that is written in a log file and here it is, ...
0
votes
0answers
30 views

Meta query orderby meta_value_num sorting by role first

I want all of the results to order by meta_value_num, but it's ordering by role first. How do I get them to ignore the role order? Here's my code: $user_query = new WP_User_Query( array( '...
0
votes
1answer
18 views

Custom Query returns array, but I can't see it's elements

guys! I have the following problem to solve - I am using Private Content plugin which divides users into categories. I need to show all posts from the category that the author is part of. I tried ...
0
votes
0answers
8 views

Creating a table from another's results using WP $wpdb functions

Below is the query and function I use to create a table from another table's results: $mytable = "myCustomTable"; $thisSQL = "SELECT p.ID, p.post_title, p.post_author, p.post_status, COALESCE( ( ...
1
vote
1answer
37 views

Duplicate Queries

While using the query monitor plugin I could notice I am making a database query 4 times. I am using OPP. So I have a method that gets me a list of posts by querying the database. I have to do this 4 ...
0
votes
1answer
45 views

Should I reset $wp_query?

I am not totally new on WordPress but the query thing is a bit confusing to me. I searched the web and read a lot of articles, but I couldn't find what I needed. Maybe it could help a lot of people ...
-1
votes
0answers
11 views

How do you query custom post types with the same category name as the post title?

How do you query custom post types belonging to a category with the same name as the default post title of the post where the post types are displayed?
0
votes
0answers
21 views

Is it possible to have 2 Args with pre_get_posts?

Is it possible to use the pre_get_posts hook using two sets of args? For example, if I want to modify my main loop to first display all products that have a tag sponsored and then display all the ...
0
votes
0answers
17 views

Static position inside an ajax-called loop

0 I am serving an output of five posts in my homepage and upon scroll down, I use an Ajax call to implement a load-more functionality, which loads a next series of 5 posts. So, upon scroll down, $...
0
votes
1answer
48 views

Custom post type order by post_title

I got a custom post type called "employees" and this is the query I use with FacetWP (plugin we are using). We want to sort the employees by post_title. <?php return [ "post_type" => [ "...
0
votes
0answers
26 views

Tags do not work

I can’t figure out how to add tag support to this code. Absolutely all posts are displayed on the tag page <?php $args = array(); $cat_id = ""; $queried = ...
0
votes
0answers
23 views

Display the terms from multiple taxonomies in a Custom Post Type

I have a Custom Post Type and I have different custom taxonomies. Every taxonomy has one or more terms. For example: Custom Post Type: Activities | Taxonomy 1 | | Taxonomy 2 | | ...
1
vote
1answer
19 views

difference between like '%%%var%%' and '%var%'

What is the difference (if any) between: $ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_product_attributes' AND meta_value LIKE '%%%s%%';", $code))...
0
votes
1answer
13 views

Including taxonomy in searches

(Fairly new to WordPress, but I'm a React / NodeJS developer) I have a basic search function that search a custom post_type (listings). It makes use of the standard built in get_search_query and ...
0
votes
2answers
32 views

SQL query to list all posts of specific post type with a specific set of associated postmeta values as a column

I want all posts of type 'ajde_events' as a row each with a column for some basics from the post table and some ( not all ) associated postmeta values. I have cribbed the following from this post How ...
0
votes
1answer
40 views

How to avoid a duplicate query from using wp_nav_menu?

My theme need to render 2 menus in homepage. The rest pages only need one. As result is only homepage got duplicate query warning. After tracking down, I found out this was cause by wp_nav_menu. How ...
0
votes
0answers
17 views

Display posts from today and future in Elementor 'posts widget'

According to Elementor documentation https://developers.elementor.com/custom-query-filter/#Multiple_Post_Types_in_Posts_Widget I need to display future posts including the post from today. We want to ...
0
votes
1answer
48 views

Custom Post type slider with thumbnail navigation

I am trying to make a slider for a custom post type with quite a few custom fields. Ive got the query and fields displaying fine. But now to get it into a slider Getting each post in the loop ...
0
votes
1answer
24 views

The search engine of my website finds only posts and not pages, how can I solve this problem?

I have a curious problem with the Wordpress search engine of my website (the one that makes URLs as http://sitename.com?s=searched+word). When I installed Wordpress I noticed that when I used the ...
0
votes
0answers
13 views

Search in multiple categories using $query->set

Right now i have this code: function exclude_categorii( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_tax ) { $query->set( 'category__in', ...
0
votes
1answer
39 views

Custom product loop avoiding duplicates

I am trying to create a product loop based on an attribute value from (pa_product-series). many products can have the same value, but I only want to return one from each...avoiding multiple products ...
0
votes
0answers
16 views

How to separate value in database column in template file?

I'am using Contact Form CFDB7 plugin to capture and store into database when user submitted a message using Contact Form 7 and i want to display list of them on the frontend inside my template file. ...
0
votes
0answers
18 views

alter the main query on 404 error page to display content from another page

I have a normal page with content that can be maintained by editors via the backend. Now I want to display this content on the 404 page. So i tried to use the pre_get_posts hook to alter the main ...
0
votes
1answer
26 views

How to get meta key list efficiently?

I have this function to get the meta keys for all the post types. public function pgggo_custom_post_type_keylist() { //gets the list of post types $...
1
vote
0answers
89 views

Category param redirect to post type archive

I'm trying to filter categories by post type. e.g: the following URI will retrieve all post from the category news. https://example.com/category/news/?post_type=post. Here is how I'm updating the ...
0
votes
0answers
74 views

how to retrieve specific product attribute value in an sql query?

I am looking for some suggestion on how to run a query on wp-term with multiple "same column name as different attribute name" bottom line I am trying to query woocommerce products + all their ...
0
votes
0answers
10 views

How to fetch data to be added to cart

I have a big problem and I need a rescue. For my website after adding a product to cart,as I check out I go to the next page for a customer to enter their shipment details. On this page according to ...
1
vote
0answers
40 views

Wordpress default Search function inconsistent in WooCommerce Product Titles

I have a custom query searching by Post title keyword for WooCommerce. But some words return no results and some words do. This simple query doesn't return all words. Words that work: Dressing ...
1
vote
0answers
30 views

WP Query related posts by tags

I want to display related posts ordered by multiple tags. So I need to create a function what will query posts with the most number of tags in common and display them in descending order. But also it ...
0
votes
1answer
18 views

add_query_arg() and empty variables inside

I have link: <a href="'.esc_url(add_query_arg(array('search' => $search, 'category' => $category, 'filter' => $filter), '/site')).'">Click</a> And some variables sometimes exist ...
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. ...
0
votes
0answers
28 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
25 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
116 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
42 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
24 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
19 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
15 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
19 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
35 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
90 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()...