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 [mysql]

MySQL is an open-source, relational database management system.

0
votes
2answers
27 views

Making a query to the DB using same parameters of loop

So, I have a loop that works great. But I need to count how many posts that loop has, and I need to do it via a query to the DB. My loop looks like: $adsArg = array( 'offset' => $...
0
votes
1answer
177 views

SQL query : Select a thumbnail for a media

I'm doing a custom gallery for a portfolio page in a website and It works well if I simply use the URL of the media uploaded this way : SELECT * FROM wp_posts AS p INNER JOIN wp_postmeta AS m ON p....
1
vote
1answer
272 views

Enabling WP_USE_EXT_MYSQL to support old plugin

We recently did a major WordPress site upgrade (3.7.25 to 4.9.4 - yes, probably shouldn't have waited this long). I set up a test environment first and thought there would be no issues. However, upon ...
0
votes
1answer
210 views

Queries take 120+ seconds on my large Wordpress site

i have a couple of Wordpress website running on a VPS, each one of them has 1M+ posts. When adding new posts queries just hangs for a long time until the website crashes. I use XML-RPC to post to my ...
0
votes
2answers
4k views

How to force update all posts after import

I recently imported large number of custom posts into wordpress. all works fine, except one taxonomy which is imported, but not show at the front end, until i click on every post "update" button. I ...
0
votes
3answers
22 views

load post data into mysql

I have a few hundred rows of product data that is going to be displayed as posts on the wordpress site. I'm sure there's a way I can load all this data directly into the database and then have both ...
0
votes
1answer
100 views

Can't update WordFence Options, clear data manually

I ran across this problem today. Found enough bits on Stack Overflow to finally get me there, but figured I'd post a coherent answer to my question. Problem: I can't save changes in WordFence, and ...
0
votes
1answer
763 views

$Wpdb post meta query is not working with mutliple meta keys and values? [closed]

I am trying to get post ids from this query $sql_query = "SELECT post_id from ".$wpdb->postmeta." WHERE (meta_key LIKE 'habitat_types_%_habitat_type' AND meta_value IN('Coastal Sage Scrub')) AND ...
1
vote
0answers
82 views

How to implement a new row_count method in Wordpress?

Overview By far, Wordpress, Implements pagination by means of SQL_CALC_ROWS_FOUND. But my benchmark have shown that this implementation is 1.1 Million % slower than my queries without it. So I am ...
0
votes
1answer
102 views

SQL syntax error when getting data for a url

I have the following SQL script: $query = $wpdb->prepare( "SELECT user_login FROM wpdb->staff as staff join wpdb->users as users on staff.wp_user_id = users.ID where ...
0
votes
3answers
74 views

WordPress select query issue

Trying to fetch all data from wp_postmeta table. I am trying to fetch first meta_key column value. so I am running this query. When I am using print_r then all data showing but when I am using foreach ...
0
votes
2answers
4k views

Send checkbox status with Ajax / JSON and save it

the task is actually quite simple I believe. I want to query the status of a checkbox, pass it with $.post and JSON to a function, and then save the value. my-html (relevant part) <input type="...
0
votes
2answers
382 views

WP MultiSite: Can't select database error after changing to new domain

I've been developing a WP Multisite on a temp URL for some time now. The site is ready, so I changed my settings around, did a find and replace in SQL from the temp domain to the permanent domain, ...
2
votes
1answer
73 views

Wordpress widget new instance creates content duplicates

I have a custom made widget that I wrote and I want to display two instances of the same widget in the same widget area. When I drag and drop new widget instance to the widget area inside admin panel ...
0
votes
0answers
41 views

Improving performance of SQL sub-queries in WordPress

We're using WooCommerce and WooCommerce subscriptions with approximately 23K users. While this question doesn't require that a user be using those plugins, I'm generally wondering how to better ...
1
vote
1answer
316 views

Update slug (URL) of pending posts via phpMyAdmin

I need to remove/delete slug of posts on pending via phpMyAdmin. Most of posts on pending have slug/URL which is different from their post title, deleting post slug/URL will force WP to generate new ...
0
votes
1answer
197 views

My custom sql query for getting a username giving me a warning and an error

I am writing a custom query to create a link to a specific username. A user will be logged in and can then click on a link to that user name. I am getting a warning and an error running the query in ...
0
votes
0answers
52 views

How to write in MySQL more characters in user_nicename

I install the plugin on the site for registration in Russian(Allow Cyrillic Usernames) and now I need to change in the sql database, in the table wp_users, in the column user_nicename permission to ...
0
votes
1answer
161 views

Inserting other fields to existing registration form in a WordPress theme

I wanted to add extra fields to my website's registration form but when I test it by creating a new account, the rest of the fields do not update with the registration. It was just Email, Username and ...
1
vote
1answer
84 views

WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another

I have a lot of meta_key and their relative meta_value associated to a post, for example, post_id = 4319. How can I assign, using an SQL query, all the values to another post_id? for example, post_id ...
1
vote
1answer
18 views

A MySQL DB within a MySQL DB

I have a client who does not want to switch hosting providers. This provider only allows one database per client. I am setting up a sandbox for the client and do not wish to share the database across ...
0
votes
1answer
27 views

How Fragile Is DB if I Upload Completely Updated Files

My localhost website is now just about perfect, can I just production that without worrying about Plugin and Theme updates dependent on DB?
1
vote
0answers
196 views

How do I query wp_options for expired transient pairs with MySQL commands?

I'm working on scanning the WordPress database from the MySQL CLI (so not using PHP to query) and getting results for expired or expiring transient pairs. The trick is the pairs have the same string ...
0
votes
2answers
309 views

use mysql to replace one custom field value with another custom field value

I have two custom fields, and both have numeric values: tnid_01 tnid_01old Custom Field 'tnid_01' exists for all posts. Custom Field 'tnid_01old' only exists for some posts. I am trying to ...
0
votes
2answers
361 views

Search and Replace in Windows XAMPP site

In my Ubuntu VPS, to search and replace in a DB of a site I do for example: cd /var/www/html/example.com sudo wp search-replace "http://" "https://" --all-tables Yet in Windows 10 I use XAMPP and ...
0
votes
1answer
397 views

The function is deprecated; use mysql_real_escape_string() instead

I don`t know coding. I recently my website stop to work properly. I get this error on the top of on every page loaded. Deprecated: mysql_escape_string(): This function is deprecated; use ...
1
vote
1answer
79 views

How are multiple Wordpress WPDB queries handled?

In my code, I use this query to get all the rows where credited field is false: $uncredited_incentives_query = $wpdb->prepare( "SELECT * FROM $incentives_table WHERE user_id = %s AND credited =...
1
vote
1answer
864 views

How can i create a WooCommerce product programatically or using sql query?

I want to add a product to a cart problematically without using the admin panel. Add to cart and then checkout using php code. So how can i achieve it and where do I place the code? I am writing a ...
1
vote
1answer
195 views

MySQL crashed because of the large number of requests

I often began to fall down mysql. I recorded a large number of requests: | 243751 | user | localhost | database | Query | 985 | Sending data | SELECT option_name, option_value FROM wp_options WHERE ...
0
votes
1answer
65 views

Moving wordpress site from localhost to live server using GoDaddy cPanel

I'm using GoDaddy cPanel hosting to move my site from localhost. It's the first time I've done this and I've hit a dead end. I've followed the instructions from these instructions. I've used ...
0
votes
1answer
254 views

Delete user meta based on key value that is an array

I have a user meta key prize which is an array contains prize type and prize date. The date in unix timestamp. How I can delete the user meta by specify the prize date only? Example code: ...
1
vote
1answer
348 views

How do I find which articles are missing a featured image in The WordPress database?

How do I search the database to find out which articles are missing a featured image on them? I looked around in the wp_posts table and searched post_type is equal to article. It gives me a list of ...
0
votes
1answer
978 views

Export Yoast Keywords from MySQL/phpMyAdmin

I'd like to export all focus keywords from Yoast, as we're moving platforms to Craft CMS and using a similar tool, Ethercreative's SEO tool. I'd love a good query to pull these from the database, ...
0
votes
0answers
502 views

Wordpress doesn't create table on plugin activation

I am trying to create a table on the Wordpress database as the plugin gets activated. My code is the following: in the main plugin file: register_activation_hook( __FILE__, 'sillyplugin_install'); ...
2
votes
1answer
364 views

How to speed up wp_query, took more 5s to run against 100k posts

I used a very sinmple wp_query to retrive 10 posts on site with more then 100k posts. This query run on wp-multi site, same query against small site in same network (same db server) took very few ...
0
votes
1answer
129 views

Delete all users meta that named: user_avatar

I want a code like this: UPDATE `jnkdadb7a_usermeta` SET `meta_key`='x1' WHERE (`meta_key` = 'x2'); I want a SQL command to search inside jnkdadb7a_usermeta table for meta_key (X) and delete it.
2
votes
1answer
281 views

AJAX in Wordpress, sending coords data to MySQL and show after into map

I've spent some months trying to figure out how to get users geolocation and pass it into MySQL and so after being shown with markers on the map. I've got stuck already in passing the data through ...
0
votes
1answer
40 views

Same database; different WordPress

I have a production site 'domainA.com', which is a multi-site WordPress installation. I have another site 'domainB.com'. I want domainB.com to have exactly the same contents and configurations of ...
1
vote
1answer
865 views

How to select WooCommerce products by post_meta and order them

I'm using the following code to select products with the following post_metas: _product_new, _product_almost_new, _product_old add_action( 'woocommerce_product_query', 'custom_vtp_shop_order' ); ...
0
votes
0answers
91 views

Order Posts By Custom Field That is an array of objects

I have a custom field called "departure_dates" which is an array of objects with the keys "start_date" and "end_date". as Json, it would look like: "departure_dates": [ { "start_date": "...
0
votes
1answer
2k views

Wordpress Site Running Extremely Slow on Dedicated Server

I have a wordpress site (link here) which runs the WooCommerce and WooZone Amazon Affiliates plugins. I have been working to optimise this site and get it running as quick as possible. Unfortunately, ...
0
votes
2answers
498 views

Valid SQL query return empty

I see the following string when I print my prepared query: "SELECT p.ID, COALESCE(w.value,Display_name) value, p.post_title, p.post_date, p.post_content,p.post_author,user_login FROM wp_posts p INNER ...
0
votes
1answer
104 views

Duplicated site isn't recognized as a site

I've duplicated a site using the following code. All code worked fine until the last row (the site itself goes up on the web but the last row of code fails and I get an error): echo "Please enter the ...
0
votes
1answer
22 views

WPCLI search and replace in a particlar site dir effect another site-dir

In /var/www/html I have a site dir. I've duplicated that site's dir and db into a new site dir and db by the name of "test" (without quote marks), and changed wp-config.php accordingly. I Navigated ...
0
votes
1answer
100 views

How can I programmatically change a MySql variable (foreign_keys_check)?

I am creating custom tables from a plugin. Foreign keys are required. To be safe, I'm want turn off foreign_keys_check before issuing maybe_create_table(). This codes is what I have to check ...
0
votes
1answer
660 views

Checking for new message using AJAX and PHP. Server overload?

I wrote a script (it may not be perfect, I'm newbie) to check for new message (using ArrowChat and Buddypress) every X mins. It works good, but I'm worried will it overload my server? It's shared. ...
0
votes
1answer
505 views

How can I export posts with featured images, without download them

Exporting posts with featured images without downloading them. I work with a site that has 10000 media in a blob and nothing is allocated in the uploads folder. How do I export the posts without ...
0
votes
1answer
22 views

How can i syn wordpress user table with a stand-alone php script?

I have a wordpress membership site running with users already signed up. I currently installed a new php script on the same mysql database which will require existing user to signup. I would like the ...
0
votes
2answers
374 views

Bulk append URL (add word to slug)

Is there a way to bulk add one word at the end of each URL for posts? I have around 3500 posts and it would be time consuming to add to each one. For example URL's are www.example.com/my-post/ www....
0
votes
0answers
467 views

Query doesn't display text data with apostrophes

I've got this code: if (is_user_logged_in()) { $user = wp_get_current_user(); $tenantsInfo = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM exp_ten WHERE tenant_number = %d ", $user->...