Stack Exchange Network

Stack Exchange network consists of 175 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
1answer
18 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
24 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(){ ...
0
votes
0answers
14 views

Extended Custom Post type get all posts in wp-json

Using johnbillion/extended-cpts I try to figure out how can I have all posts in wp-json response. Till now what I tried did not worked I registered the post as it follows ...
0
votes
0answers
9 views

Problems logging on what does this mean [duplicate]

Warning: Declaration of thesis_comment::start_lvl(&$output, $depth, $args) should be compatible with Walker::start_lvl(&$output, $depth = 0, $args = Array) in /homepages/28/d429127183/htdocs/...
0
votes
0answers
19 views

Passing URL parameters to WordPress buttons

I'm beginner with programming and web development. I have a WordPress website (http://www.example.com). My post link is http://www.example.com/mypost/, so when I click on a button (assuming demo 1 ...
0
votes
1answer
18 views

SQL query, error

I have sql query but not work, i have notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE custom > ...
0
votes
0answers
35 views

SELECT max(meta_value) FROM wp_postmeta in current Category

I need to display the maximum price and minimum price of product From the current category I found this topic SELECT max(meta_value) FROM wp_postmeta WHERE meta_key='price'... stops working ...
0
votes
1answer
80 views

add_query_arg not work in admin

I have code: class some{ public function run(){ add_filter('query_vars', array( $this, 'addPar')); $this->some_body(); } public function addPar($vars){ ...
0
votes
3answers
25 views

I have Wordpress setup on primary domain, how do I set it up on its subdomain using the same database?

I have a site www.domain.com with Wordpress installed. I need to create a subdomain for testing a new theme and have it linked to the main site's database. I have manually added the Wordpress files ...
0
votes
1answer
25 views

Query Post interferes with Pagination

Here is my situation, if you look at the following page: http://staging.cancerwellness.com/mind-body/cancerversary/, you will see that the pagination is not working. After researching the problem, I ...
0
votes
0answers
19 views

Sort custom post type by other custom post type field. (Places by their reviews mean vote)

I'm trying to sort Places (first custom post) by its Reviews (second custom post) average (mean) vote. So, basically I have two custom post types, one is Places and the other one is Reviews. Reviews ...
0
votes
0answers
14 views

Woocommerce in-stock only with product filter

I have a function that is pulling only in-stock items in Woocommerce. It's working properly but I need to be able to sort them alphabetically and then also have a dropdown filter so customers can ...
0
votes
1answer
25 views

SQL query to delete users with multiple meta keys and comments

I need help putting together an SQL that can delete users if they don't have (metakey1 or metakey2) and (does not have comments) I have this SQL which does it for single meta_key SELECT * FROM ...
1
vote
1answer
50 views

Get posts by category with pure SQL query

I have a meeting post type, whose titles automatically get set to a date of the form m/d/Y. I have the below query which gets all unique years from the post titles by selecting distinct values after ...
0
votes
1answer
14 views

Parse error: syntax error, unexpected '}' [closed]

<?php if(empty($username)) {array_push($errors, "Username is required")}; ?> i put this line inside a php file but there is a problem with it, can someone explain what I'm doing wrong?
0
votes
1answer
16 views

Query Posts | Combining multiple form inputs into query arguments to generate one filter result

I am trying and so far failing to take two form inputs and combine them into a single post query. I have tested these forms as two separate forms and both return results as expected, I am now trying ...
0
votes
1answer
23 views

My custom pagination not displaying

I'm testing a custom pagination feature but my pagination is not showing, is there something I forgot to do? here's my arguments and query inserted in my template: <?php ...
0
votes
1answer
25 views

Connecting to a different database

In my site I'd like to pull in data from another table, without having to create an API from the other site. I have seen that you can do something like this: $wpdbtest_otherdb = new wpdb('...
0
votes
1answer
34 views

SQL query to bulk change short code in all posts

PHP/SQL noob here. Based on this question I attempted to change some entries in phpmyadmin for my wordpress blog: I want to all galleries to link to file instead to file attachment (add link="file" to ...
0
votes
0answers
42 views

ACF Loop Relationship Field Posts by Custom Taxonomy Term

I'm using the 'Post 2 Post for ACF' plugin (https://wordpress.org/plugins/post-2-post-for-acf/) to link 2 ACF relationship fields, for 2 different Custom Post Types. Everything is working great but I'...
0
votes
1answer
18 views

Why does a header location on admin_head remove the query var I'm setting in the location?

I have the following code which I thought would load the location with a query var of saved=1. public function __construct() { add_action( 'admin_head', array( $this, 'test' ) ); } public ...
0
votes
1answer
31 views

Strange results from WP_Query

I'm trying to retreive a set of custom posts using the following: // set search conditions $args = array( 'posts_per_page' => -1, 'post_type' => 'fee', 'meta_key' => 'fee_code', ...
0
votes
1answer
23 views

Admin table Query filtering “WHERE” for custom post type

So I have been searching for a solution on how I can dynamically change a CPT admin table query by filter the result WHERE Status is equaled to some custom status. I have searched using function ...
4
votes
1answer
66 views

How to know if get_posts() failed?

So I see that get_posts() function return an array of posts. If there are posts, it returns an array of posts. If there are no posts it returns an empty array(). If there are posts, but the querying ...
0
votes
1answer
6 views

How to hide sub fields in a field group and also the entire field group if the answer selected is “no”

I have a field group (repeater field type) set up (titled "Units") with sub fields; sq footage, floor plans and availability (this is a yes/no selection). I have the availability sub field to display ...
1
vote
1answer
25 views

Using $wpdb->update but confused on the WHERE in and SET

I'm confused on using the where in the $wpdb->update :/ These last few lines of my code are MEANT to update a table with an IP address when software is activated. If they change IPs it records the ...
0
votes
0answers
12 views

Can I replace the “Upgrade Network” with SQL query?

I have a WordPress Multisite network. When the WordPress version has been updated, I have to click on "Upgrade Network" for do same thing on all subsites. How can I replace this function with one SQL ...
0
votes
1answer
37 views

DELETE WooCommerce Order data from database

I spent some time in my DB trying to figure out how I can clean out some completed order data. Below is the query that I am confident will help remove the data from completed woocommerce orders. My ...
0
votes
1answer
22 views

How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page

Let's assume that the $wpdb->query() is properly escaped as needed, so there is no must for use of $wpdb->prepare(). However, some new requirements at Envato, not the w.org, requires to go over ...
0
votes
2answers
16 views

Is there a way to control both Order By and Order query parameters from one input field

I want to give the user the ability to order posts by post date/alphabetically either on ASC or DESC order through a select input on an archive page. The easy way would be to show two inputs on the ...
0
votes
1answer
15 views

Wp admin ajax load more

can someone explain to me how to include load more for archive, custom post type? I’ve been looking all over internet for a way to use it but can’t seem to find anything
0
votes
0answers
39 views

How to get_comments() ordered by date and parent?

So my starting point is: <?php $comments = get_comments(array( 'post_id' => $post->ID, 'status' => 'approve', 'type'=>'comment', '...
0
votes
2answers
26 views

WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category

I'm trying to do a single WP_Query to get the posts that are in 2 different custom post types but the second post type has to be from a specific taxonomy. This is what I'm currently doing: $...
0
votes
1answer
54 views

Is it possible to query from external database? [duplicate]

I have an extarnal database that I want to show some data in my wordpress site. What are the necessary steps to achieve this? edit: I changed config.inc.php according to https://stackoverflow.com/...
1
vote
0answers
58 views

Filter posts in category archive page by year using a dropdown

I'm trying to filter my posts by year in different categories by changing the query using a dropdown with this code: <form method="post" action=""> <...
1
vote
1answer
163 views

Order by summing multiple values

In a custom post type (products) I want to order products by summing multiple values based on user selection. I use custom taxonomies to filter the products. I could use the orderby meta_value but ...
0
votes
0answers
34 views

What is this Query? and why its taking too much time? Any way to optimize it?

Query: SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND tt.count > 0 ORDER BY t.name ASC; Query_time: 3....
0
votes
1answer
24 views

I have two post types in the same query, how can I use CSS to select only one post type?

I'm using OceanWP theme and Elementor at this site: https://mymythos.org/ Ritual, Relaxation, and Motivation are examples of the second post type. Most of the other posts are normal WP posts.
0
votes
1answer
26 views

WordPress Database Query works in phpMyAdmin but not in the code

I have a simple SQL query: SELECT * FROM test_table__csv_import_temp_joblist WHERE url ='https://www.example.com' In phpMyAdmin, it works well and returns a result. In WP it returns nothing: $sql ...
1
vote
2answers
238 views

How to create a WP_Query to search the Title or Tag?

I have created a search using WP_Query, it seems like this query is looking for the queried term in title AND tags. Is there a way to have this search the title OR tags? $s = $request['s']; $tags = ...
0
votes
0answers
35 views

Set global $wp_query/$post variable for dynamic page generation

This is a difficult one to describe, but I'll do my best... I'm trying to set up pages that can be shown based on a second (meta/ACF) slug, dependent on the language the user is using. Essentially, I ...
0
votes
1answer
54 views

Plugin echos text from shortcode function in gutenberg page editor

I'm creating a plugin to load custom posts by custom taxonomy (restaurant menu plugin).. I'm calling the main function (holds everything) by the add_action hook on 'init' and inside it I have another ...
0
votes
2answers
21 views

How to give classname to post if post has no content?

I want to give a post a classname on the homepage (index) if the post on the single page has no content. So when the post itself exists but there is no content, I want to give a classname to that ...
0
votes
0answers
37 views

How to add variables to a template

I am using a query argument detail to check if a custom template should be loaded. This works fine, but I also need to add some variables that can be accessed from within the template. Here I am using ...
0
votes
1answer
14 views

How to exclude posts for current user

How can I hide posts that are in an array of ids in the usermeta for the current user in the main query. I can use post__not_in in meta_query but I do not know which option to use for only a specific ...
0
votes
0answers
26 views

Get count of each category depend on date - SQL query in WP

I would like to select all categories of my blog with count and date of create. I know that I have to convert post_date to specific month and then group my select by month(date) and category. However ...
0
votes
0answers
41 views

Query users by custom field

I want to get the users who registered within last 7 days, and meanwhile who have uploaded custom avatar. I've added a function allowing users to upload their own avatar img with a custom field ...
1
vote
1answer
32 views

Print terms with taxonomy and metabox value

I create metabox serial_language with ACP plugin into custom taxonomy name is serial. And I want to get only terms, in which custom field value is english, arabic. How to get only terms which have ...
0
votes
0answers
15 views

Having issue with dynamic data within restrict_manage_posts function

I have the dropdown dynamically populated with the titles of my podcast post type and I can successfully apply a filter by selected a podcast title and clicking filter. However, when the page loads ...
0
votes
1answer
22 views

I can't figure out what's wrong with this statement. $wpdb->query update

I'm trying to use the $wpdb-query method, but can't seem to get it to work. I get a 500 error when I try the following: $update_status = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}...