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
0
votes
1answer
729 views

Using wp_list_table how to trigger update function “inline”?

Ok, i have used wp_list_table to read data from a custom db table and i like to be able to update the database table by clicking the correspondig cell. Defaults are 0 and when clicked the value is set ...
0
votes
3answers
924 views

Find woocommerce product ID by custom field value?

I try to find a way to get products ID by custom field in a category. I use this: // Get the category $catsearched = $atts['category_id']; // Get all product of categoryselected $product_args = ...
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
2answers
1k views

How to display a specific category using a custom Query in WordPress?

Hi I want to display a specific category from a custom query in WordPress. My code works fine and it gets the latest 4 posts, but what I want now is to retrieve a specific category. My code is below ...
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
2answers
698 views

Comparing timestamps in meta query doesn't work

I want to compare two timestamps in a meta_query instead of comparing two dates in the "Y-m-d" format, each of them stored separately in custom fields, but no success. The first timestamp is an event ...
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) ...
1
vote
1answer
2k views

How to get list of posts from permalinks?

I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those ...
1
vote
2answers
2k views

WooCommerce: Can't use wc_get_products for custom REST API endpoints

I'm trying to create some custom REST API endpoints which get products with some special conditions, for example one endpoint for featured products. I tried to use the wc_get_products function like ...
0
votes
1answer
2k views

Create custom query for search?

I have create search box using ajax.If i enter any value in search input box that this value search in post title or post meta data and get all data of this value in custom post type.also query check ...
1
vote
2answers
749 views

How to retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently ...
1
vote
1answer
580 views

MySQL variable in query

I've got tenant portal when I need to show running balance for each transaction. Here's query I've written which does what I need it to do. Problem I've got is that it doesn't work in Wordpress. Here'...
3
votes
3answers
3k views

Get category slug and display it on a query_post

I just read "How to create option page for wordpress theme" in wp.tutsplus.com - I have a problem with getting categories . there is two parts to my question - Part A - Get category slug and ...
0
votes
1answer
1k views

Search / Filter posts on Title/Content OR Tags

I need to make a custom query to look for posts (CPT) which match a certain keyword but it have to search posts in both the title, the content AND a custom taxonomy terms. I’ve tried with to queries ...
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 $...
0
votes
1answer
418 views

Help ordering custom query by Title, Ascending

I have an old project (custom post type query) that needs an alteration and my memory/skill level is lacking for what to do. With the code below, I'm needing to return the first query in alphabetical ...
0
votes
1answer
876 views

wpdb get_results() returns only 2 rows

I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global $wpdb;...
0
votes
2answers
865 views

You have an error in your SQL syntax - Help with query

I have a programmer that developed a custom plug in for a client's website and after moving the site to client's server, some parts are not working. Looking at the error log, there is an issue with ...
0
votes
2answers
630 views

Query posts by meta value and sort by another meta key

I would like to query and sort posts by meta key "popularity" and these posts must have also another meta key "gone" with value "1" to query $args = array( 'post_status' => 'publish', ...
0
votes
2answers
473 views

How to run select query of post with category and tags?

I want to fetch multiple posts with categories and tags currently I'm using this query: $pagesize = 20; $pageNumber = 1; $mysql = mysqli_query($con,"SELECT p.post_title, p.ID, p....
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 ...
0
votes
1answer
447 views

query specific posts according their custom fields, using sql SELECT

My posts have a bunch of custom fields, to help insert and display custom info easily. I am trying to build a search that would select and display posts according values of specific 2 custom fields. ...
0
votes
2answers
1k views

get_terms (or tax_query) for term of current post?

I've seen many solutions but none seem to work for me... I've got a grid off the loop/content on single.php that renders the whole grid as is, so I use the function as below which works fine, but only ...
1
vote
1answer
2k views

Query custom post type by custom taxonomy (category slug)

I've followed several related solution. But I'm still facing the problem. I've applied the following code for my custom post query by taxonomy (category). But it's not working. I think my problem with ...
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
1answer
655 views

Search Terms - Querying on either description__like OR name__like in the same Term Query?

In my theme's search.php I have a section set up to show terms that fit the search. I want the term to show up IF the $keyword appears in the term's title or its description. I have it set up to do ...
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"> <...
0
votes
1answer
449 views

Custom Select Query pagination not working properly

I have Custom Select Query joining two tables and displaying events older than current date. Everything works fine until I try to paginate it. <?php global $wpdb; $date = date("Y-m-d");...
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
2answers
534 views

mysql query - how to escape apostrophe?

I've got this query: $tenantsInfo = $wpdb->get_results("SELECT * FROM exp_ten WHERE tenant_number = " . (int) $user->ID); I use some echo to show data on frontend: if ($tenantsInfo) { ...
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 = '...
1
vote
2answers
651 views

merge two query arguments into one WP_Query call

I'm overriding WooCommerce's default search query to include searching by SKU as well. // default search query $query_default_search = new WP_Query( array( "post_type" => "product", ...
1
vote
1answer
2k views

Modifying date filter on admin page for custom post type to link to custom field

Apologies if a similar question has already been asked, but I can't seem to find the exact functionality I am looking for. Basically I have a custom post type (sermons) which has 'recorded_date' as ...
2
votes
5answers
9k views

Get wp_get_attachment_url outside of loop

I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able ...
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
1answer
3k views

Is it possible to add query parameters on the archive page?

I have a custom post type 'Works', and an archive page 'archive-works.php'. I would like to hide the non-public posts from the archive page, so I added a custom meta box. I also modified the query to ...
2
votes
1answer
702 views

Order post by year DESC and month ASC

I have a worpresss 4.0.12 website; i created a custom template category-$id.php in which I have to show post ordering them by Year DESC and by month ASC (or a custom field ASC), the result should be ...
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 ...
6
votes
2answers
22k views

Custom Search Query

I'd like to set up a custom search page that does the following: User checks off several items in a form that he'd like to see returned in his search (essentially choosing from a list of tags). ...
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 ...
3
votes
1answer
457 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...