A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [query]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
19 views

Alter query with posts_clauses to retrieve NULL values last

I'm running a query to order my posts first by book's author, and then by book's name. I'm trying to achieve something like this : Author A : Book A Author A : Book B Author B : Book F Author C : ...
0
votes
1answer
23 views

Is it possible to apply filter to meta key value when querying posts?

I am querying my posts and I am applying pricing orderby sorting filters below. But my product_price_from meta field contains a number which is inputted as various currencies. GBP, USD, AED etc. ...
0
votes
0answers
16 views

How to create a dynamic content from second segment uri?

First, I have to say that I spend many hours to research but still no luck and I am not sure if I am in the wrong point or even I have no idea what I have to looking for. I have created my custom ...
0
votes
1answer
22 views

Move some posts to end of sort order, even if there is a sort in the wp_Query already

I have a site that lists properties for sale. I have a custom wp_query, with a sort dropdown I created. This dropdown reorders the posts query by date, price (low-high & high-low) and beds (low-...
0
votes
1answer
19 views

Why isn't comment validation working?

I am trying to add Jquery validation to the comments page in WordPress. Everything works except it won't post the fields. May someone help? Comments page: <?php foreach (get_comments() as $...
0
votes
2answers
16 views

How select query is generated in a Custom Post Type?

I have this table that is generated in a Custom Post Type (CPT) Is there an option that I can modify the query? For example, I have this post_type = 'my-type' in wp_posts table. I want to do a JOIN ...
0
votes
0answers
9 views

Sql query to update urls automatically for future posts?

how can i update one url to another for upcoming post automatically. For ex. if "google.com" appear in any upcoming post update it automatically to "fb.com". Any code or plugin to do that ? btw i ...
0
votes
0answers
4 views

Query custom post type by custom datetime field, later than field datetime value

I need to Query custom post type (esemeny) by custom datetime field,and show only later than posts that the meta value field datetime. My code working properly but i dont know how to add a Later than ...
0
votes
1answer
21 views

Foreach-generated custom tax queries, each with an ajax “Load more” button

I'm looping through custom taxonomy terms to create a WP_Query for each term, then displaying the posts on the front-end. I'm also attempting to adapt this helpful tutorial(and accompanying comments) ...
0
votes
1answer
18 views

Query not work for current taxonomy

Hi i want to show current taxonomy post type count by month but it show total post count istead of current tax. please help me. i am trying to solve this problem almost 3 weeks. <?php $...
1
vote
4answers
43 views

Show Two custom Post type and their posts on category page

I have Two Custom Post Types "Article " & "News" and they both use same categories like [ audit , income , tax] . I want when i open audit category page then the post showsn like below: the code ...
1
vote
0answers
20 views

WP_Query search posts by custom post type and custom taxonomy

I have custom posts articles with custom taxonomy tags-articles, I need search all posts with have the term in title, or taxonomy associated with same title (or partial title): Example os published ...
1
vote
0answers
18 views

creat filter with wp_query

I doing make a filter with wp_query for a custom post type. I create my page and I want to include a filter by date (year) with wp_query <?php get_header(); ?> <div class="row"> <...
1
vote
1answer
10 views

Order RSS content by an advanced custom field value

I have created a custom post-type called "event". For this custom post-type I created an advanced custom field called "event_date". Now I am trying to display the list of my events in a RSS feed. ...
0
votes
0answers
8 views

Unable to upload a post in a particular menu

I am facing an issue during posting a post. In the subsection, I am not able to post in the same subsection. After selecting the same category, it's displaying as another menu. As shown in the picture....
1
vote
0answers
68 views

Slow queries constantly getting stuck on Wordpress database of ~100,000 posts

I am constantly getting stuck SELECT queries on my wordpress databases like the following: Many of the SELECT queries that get stuck are fairly ordinary, such as pulling the last 10 posts of an ...
1
vote
0answers
23 views

How to use the query hook/filter?

I want to stop this query from running: SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_author IN (1) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = '...
0
votes
0answers
31 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
14 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
20 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
47 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
31 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
28 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
100 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
32 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
10 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
45 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
49 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 ...
0
votes
0answers
25 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
50 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
27 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
14 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
37 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
71 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
28 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
53 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
15 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
52 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
20 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
27 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
91 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
121 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 ...