Questions tagged [sql]

SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).

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

Change word in woocommerce product category custom field

I have woocommerce shop with a large number of categories that have a filled custom field "custom_title". Each custom field has the word "Category" and I want to replace it with ...
0
votes
0answers
9 views

Change published date and time using SQL query for page in every 5 hour

If I want to modify publish date and time every 5 hours every day and before modifying the date I also want that for 1 second that post should be drafted then in the next second publish the particular ...
0
votes
0answers
11 views

WP Optimization: Removing Orphaned wp_options (especially the autoload ones)

Is there no mechanism which purges old options from the DB? I tried a few plugins in the past and I found out that there are a few pretty long option strings which are set to autoload but IMHO not ...
0
votes
0answers
6 views

WP Optimization: Overwriting options to autoload=yes for often used options?

I'm currently trying to optimize my WP-page. I checked with "Query Monitor" and I see a lot of options which are fetched on every pageload (not a huge runtime cumulated, but still ~15-20 ...
0
votes
0answers
24 views

get different meta-data of a complicated query at the same time

I have a function that generate a very complicated query with meta_query, tax_query etc. and now am using it in a filter page. i need to fill the filter page by some meta data, like number of paied, ...
0
votes
0answers
9 views

Data is not constatntly loading from custom wordpress table

global $wpdb; $tablename_temp = $wpdb->prefix . 'faculty_temp'; $toke = $_GET['token']; $user = $wpdb->get_results("SELECT * FROM $tablename_temp where token='$toke'"); This is to ...
0
votes
0answers
28 views

Wordpress SQL Prepare

i'm trying to adapt this code to also take in to account specific categories and custom post types, so it would give me select dropdown populated with unique custom field values, from a specific post ...
0
votes
0answers
14 views

Accidently changed the GUID

I accidently executed: UPDATE yemnc_posts SET guid = REPLACE(post_content, 'domainA', 'domainB'); instead of UPDATE yemnc_posts SET guid = REPLACE(guid, 'domainA', 'domainB'); How can I undo this? Is ...
0
votes
0answers
20 views

Passing a SQL query to the WP Query

I'm writing this filter and would like your help in fixing the following this code. I will like to take the SQL statement below and place it in a WP query. select post_id from wp_postmeta WHERE ...
0
votes
1answer
16 views

Why line returns are not reapply after doing esc_sql?

I trying show data from my database. This data was escape by esc_sql like bellow. But when I use it in echo, line-returns are print as normal chars ('\', 'r', '\', 'n'). $data = esc_sql(" ...
0
votes
0answers
14 views

How to set wordpress url on local host to access it via VPN

I have an issue. I have wordpress installed on raspberry PI that is connected to my home local network. I have a conenction to this pi via hamachi VPN. The issue is that in SQL database there is url ...
0
votes
1answer
36 views

Build A Custom SQL Query for WordPress Search

I was working on a code, where I used SQL to find something on my site. I realised that the SQL was giving me far accurate search results, and wanted to implement the same in my WordPress search query....
0
votes
1answer
20 views

Getting rid of unwanted nonSQL syntax characters when debugging a query

I am trying to debug a SQL query, but I am getting a lot of @r and other unwanted characters right before I run the query like so: print_r($query); die; $rows = $wpdb->get_results($query); I get: ...
0
votes
0answers
22 views

How to run complex query using PHP

I have a rather long and complicated SQL query. I want to use commands like SET @varible, GROUP_CONCAT, PREPARE, EXECUTE, DEALLOCATE PREPARE, case when, etc. I need this data from the DB to construct ...
0
votes
0answers
20 views

Menu Order updating automatically

I have a custom post type with page-attributes declared so I am able to put in a menu_order number/field for sorting them via menu order. This all works as expected except this next issue. I reset all ...
0
votes
1answer
21 views

Storing huge number of users in wordpress

I would begin coding a school management theme project soon and am looking to keep the DB neatly organised. In this pursuit, since the students could be thousands in a school, would it be a good ...
0
votes
0answers
25 views

Custom SQL query slows down when using multiple OR ... LIKE ... in posts_where filter

I have built a posts query that includes a custom table in search using the posts_join and posts_where filters. Now the customer wants me to include yet another custom table in the search, but doing ...
0
votes
1answer
18 views

add role on WordPress in PHP on a second database

I have a site A (a store) where once the purchase is made the new user has to register in site B (a members area). To do this I connected the second database and also managed to pass the various info ...
0
votes
1answer
58 views

WooCommerce database query : Get product category image path+name from thumbnail_id [closed]

I am trying to list all my Woocommerce Product Categories | category name | category slug | ... | ... | category image path+name | Using this query below, gets me most of the way: SELECT * FROM ...
0
votes
0answers
43 views

DB prefix not updating

I have a site I built locally and migrated to a live environment. Later I created a copy of this site and booted it up locally again to do some further dev in there. My local dev software (Local by ...
0
votes
1answer
37 views

Trying to create a shortcode to display categories with a specific product tag

I currently have the following and it is not working: If I put the shortcode [tagtagtag=246] i get an array to string error function get_categories_with_product_in_tag( $atts ) { $atts = ...
0
votes
1answer
66 views

SELECT custom post type and its meta in SQL

So I have the following SQL script where I can view all my post_meta with specific meta_keys: SELECT * FROM `wp_postmeta` WHERE `meta_key` = 'honorific' OR `meta_key` = 'suffix' OR `meta_key` = '...
0
votes
0answers
26 views

SQL DELETE multiple post_meta on single and multi-sites

So I don't have too much knowledge on SQL and running scripts, so I wanted to see if the community can help me. Here is what I'm attempting to do: Delete all post_meta that has the meta_keys honorific,...
1
vote
0answers
31 views

Bulk-create posts from SQL database

I'm new in this forum and fairly new to Wordpress as a whole, so I hope I will abide by all written and unwritten rules when posting this. I have an SQL database with around 4,000 posts from an old ...
0
votes
1answer
22 views

WP_Query() not working as expected

I'm building a plugin for EDD which adds a custom metabox with checkbox option meta_key _xy_global_product. So far, so good. In the frontend, I'm trying to filter posts which have this meta_key set to ...
0
votes
0answers
46 views

Deleting empty meta key values

Is it safe to use DELETE FROM wp_postmeta WHERE `meta_value` = '' in SQL in order to remove meta keys with empty values? Could any errors or problems occur?
0
votes
0answers
23 views

Fetch Data from an external MSSQL Database in a Managed WP hosting

SO, my client is using a managed WP hosting, which is why I can't install MSSQL drivers in his server. I am building a plugin for him to fetch some data from their office's MSSQL server. Now, I have ...
0
votes
1answer
54 views

How I can change the condition or compare operator for WP_Query in pre_get_posts

So here is my problem I want to show Posts if have same category if not have post then show post of same tag. And to do that I am using "pre_get_posts" action. and setting query like ...
0
votes
2answers
74 views

Increment integer field in database when WHERE needs to be dynamic [closed]

I have a database column called "upvotes". I have another column called "userid". I would like to increment the value in the "updates" column where the userid matches the ...
0
votes
2answers
50 views

Do I need to sanitize $_POST['keyword'] before send to 's' parameter?

Anyone know how to sanitize the $_POST for wordpress? $args = array( 's' => esc_attr( $_POST['keyword'] ), );
0
votes
0answers
29 views

Cannot get sql request from Query object?

$qry = new WP_Query(array( 'post_type' => $this->type, 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => "_{$this->metaPrefix}...
0
votes
1answer
17 views

add products to WordPress site automatically

i have a products sql database table from none WordPress old site with names description and category fields but the category has only id from category table and i have to move all these products and ...
0
votes
0answers
61 views

How to get image path from id using SQL

I want to use a SQL query to get some random users and display an advanced custom fields profile image. Currently with this query I get the image ID back but I somehow from that need to get the url ...
0
votes
0answers
48 views

How to query results for post_title and Custom Post Type/ACF field pivot query

I have a custom query that needs to match a search term to a custom post type of event by post title and by an ACF field host and then filters out events that have passed the current date to a REST ...
0
votes
1answer
15 views

I want to get on those users their meta value are like "AGENT" .. but this query is not working

SELECT display_name FROM $wpdb->users WHERE id IN (SELECT user_id from $wpdb->usermeta where meta_value LIKE '%agent%')
0
votes
0answers
13 views

Taxonomy list inside the query

Is it possible to get a list of the "terms of taxonomy" or "just used taxonomy types" defined within that archive without looking at all pages of an archive query in a loop? What I ...
0
votes
0answers
26 views

Customising the default wordpress search functionality

I find the current from WordPress too strict as it doesn't allow for some minor spelling mistakes. How can I edit this function? I was checking out pre-get-posts however I don't think that allows me ...
1
vote
0answers
22 views

Editing the default wordpress search

My wordpress sites search function is not relaxed enough for my liking. I want it to match more items and be less strict. How would i do this? I was thinking it would to do a pre-get posts filter but ...
1
vote
2answers
33 views

Difficulty importing my live site to local

Im using local by flywheel, Here are the steps i have taken so far: Installed local by flywheel and created a site called stage Downloaded the website from CPanel and also the SQL database Imported ...
0
votes
1answer
201 views

wpdb->get_row is selecting the variable as a column name

I'm using wpdb to get a row of a table $file = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}vip_files WHERE {$file_hash} = `hashcode`&...
0
votes
1answer
23 views

Run a sql (update) after 12 hours after the user login. Woocommerce users

How can I Run a sql (update) after 12 hours after the user login (for Woocommerce users) After 12 hours after a user login, I want to run a sql/ function to update a value in the database. To set a ...
0
votes
2answers
117 views

Display data from phpMyAdmin with WordPress

I have imported my website to Wordpress and facing a big issue how can I do sql Query to display data on my pages with wordpress? for example I have product, price, description which I need to display ...
0
votes
0answers
51 views

How delete post_content records of specific category from phpmyadmin

I need a SQL command to delete post_content records for specific category's posts
0
votes
1answer
114 views

SQL Bulk update all Wordpress user's nicknames to firstname + lastname format

I'm trying to bulk update all my users on one of my Wordpress sites to so that their nicknames aren't the default username but have the format firstname + lastname instead. I've put together this code ...
0
votes
0answers
68 views

Sql query to get all metadata for a post

I have three tables in my database one is users table the other is posts and wp_post meta. In the user table I have all the user details . In the wp_posts table I have different posts types . I want ...
0
votes
1answer
52 views

How to get database connection details without longing to cpanel in WordPress?

I am creating a WordPress plugin and in my plugin i need to do some SQL statements ,in the site i am working on i have access to WP-admin but i cant get to the files to get database name and password ...
0
votes
2answers
23 views

Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?

With a default Wordpress install, with no plugin installed, does the read-only visiting of the website generates write operations in the database? By read-only, I mean: visitors come and don't post ...
1
vote
2answers
112 views

Syntax for $wpdb->prepare when searching in two columns

I have this working statement for searching a single column in my database: $foods = $wpdb->get_results( $wpdb->prepare( "SELECT id, foodname, namevariations, calories, carbs, fat, protein, ...
0
votes
0answers
70 views

Creating multiple tables with Plugin

I opened a new question, just to be sure. The former request has partly been resolved. I got another question regarding creating tables for wordpress: Only one table is created (The first one), but ...
1
vote
1answer
47 views

Problem with creating tables for Plugin

I hope someone can help me. I try to execute this code to install the tables for my Plugin. But for some reason it doesn't work (Doesn't appear in my wordpress database) and I can't find out why. Can ...

1
2 3 4 5
16