Questions tagged [mysql]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
257 views

Changing user_nicename

user_nicename has the same value with user_login. I want to change user_nicename value only by using code snippet into functions.php or wp-config.php. Is it possible without using phpmyadmin or any ...
1
vote
1answer
926 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 ...
0
votes
1answer
24 views

Sql Update CPT from publish to draft and particular custom field

I have: CPT: match custom field: played Is it possible by MySql to change the status from publish to draft of all posts of CPT 'match' with custom field set as '0'? A good start can be UPDATE ...
-1
votes
1answer
27 views

Add a navigation menu item using MySQL

I want to insert Wordpress nav menu items into MySQL using PHP. I dont think i can use wp_create_nav_menu() because I need to build a preliminary menu from the categories (over 100 cats!) then a ...
0
votes
2answers
128 views

$wpdb->prepare with LIKE and sprintf

Ok, I know similar questions have been asked before but none of the answers I found seem to work. Here's my code: $sql = $wpdb->prepare('SELECT ID FROM ' . $ignore_url_table_name . " where url ...
0
votes
2answers
104 views

AJAX Implementation

Am try to implement data from database using AJAX based on a drop down list in WordPress. The codes returning 400 bad request in the console. I am hosted the page as localhost. Here is my theme's ...
1
vote
1answer
391 views

How to handle 400 status in Ajax [duplicate]

I have created a page in wordpress which is hosted in localhost. The page containing two drop down lists. one is for selecting category lists from a table called 'category' and the second drop down ...
0
votes
2answers
26 views

How to configure Wordpress Database for CentOS 7

I'm trying move an existing Wordpress site to run across two different servers, one with Apache and the main source code and the other that just has the database running on MYSQL. wp-config: define('...
0
votes
1answer
380 views

WordPress database error Duplicate entry for key 'slug'

I have just migrated to a new host and upgraded my Wordpress to 4.9.8 (from 3.9.x, embarrassing I know, plan to keep it up to date from now on). I also went through the process of replacing plugins ...
0
votes
1answer
36 views

WordPress Database Posts Table query

This works if I replace $wpdb->posts with the literal table name in the database, but not if I try to switch it over to $wpdb->posts. I thought this is used to solve the databases being named ...
0
votes
1answer
43 views

Search returns “Nothing Found” on a sub directory

I've created a multisite using subdirectories. The search function, both in backend and frontend, only works on the main site. If I try and do a search in a subdirectory it returns with "Nothing Found"...
0
votes
2answers
79 views

Case insensitive ORDERBY in wpquery

I'm trying to sort custom posts in alphabetical order, and I've just now realized that capital letters are being sorted before lowercase. Two restaurants start with 'Cal' and 'CAT' with 'CAT' being ...
0
votes
1answer
131 views

Delete posts with word count less than x number of words

I searched a lot about this, found plugins that are out dated and consumes massive resources and finally do nothing, is there like an SQL line to delete all posts that have a word count like less than ...
1
vote
0answers
22 views

How to delete posts that does not have a thumbnail?

I have a problem with my blog. The thing is this, all the posts have a thumbnail in this address: wpbv_postmeta-->meta_key-->thumb And several (A LOT) of posts don't work, because I have made a ...
0
votes
1answer
83 views

The plugin generated 225 characters of unexpected output during activation

I am getting the famous "The plugin generated xxx characters of unexpected output during activation." error when I activate plugin I am working on. Terminal says my files are in us-ascii, but when I ...
0
votes
1answer
183 views

Update a user meta key based on WooCommerce product purchase

I have a WooCommerce shop. I have a custom user meta key for user expiration that I need to update based on the result of all users who have purchased a specific product. Unfortunately, I have not ...
0
votes
0answers
243 views

Get menu items in MySql Wordpress database via sql query

There is menu 'menu-name' on wordpress site. On wordpress I can get menu by $menu_items = wp_get_nav_menu_items( 'my-menu' ). Then in foreach loop I get url for menu item: $url = $menu_item -> url. ...
0
votes
0answers
21 views

AJAX request returns back Array0 to console

I'm making an AJAX request in wordpress for the first time and I'm trying to access my custom made table to retrieve single name (string) or multiple names. It all works without the errors, except for ...
2
votes
0answers
162 views

Find duplicate posts with same slug and author

We imported over 250K posts into our multi-author WordPress database but have found duplicate posts where the same author has multiple posts with the same slug. Could you please recommend a MySQL ...
1
vote
1answer
540 views

How to get data from WordPress site sql file

I have an SQL file of my WordPress site but I lost my project files. So if I import the sql into my DB then can I run the sql with new database file? Or is there any other way to back the previous ...
1
vote
1answer
881 views

Updating a checkbox value to database for specific row in table

I have written a custom plugin for people to sign up to a course. The data is submitted in a front end form and stored in a custom table in the database. There is a "course_completed" column that is a ...
0
votes
1answer
364 views

Comment Approve - Add custom function when comment is approved

I would like to save some PHP memory when quering category page (like 5000 products at once) with average review rating, so I would like to save average rating of reviews every time I will manually ...
0
votes
1answer
33 views

Unexpected behavior when trying to manually install Wordpress on macOS Sierra

Server Configuration macOS Sierra 10.12.6 Server App v5.3.1 (Websites Service is ON and serving other sites) mySQL v8.0.12 (Verified up and running) PHP v7.2.10 (Verified through phpinfo()) Wordpress ...
0
votes
1answer
43 views

DB Query not working in Plugin

I am working on a plugin. And I want to create a table via the plugin. So I am trying execute following SQL Query. global $wpdb; $createSQL = " CREATE TABLE `". $wpdb->prefix ."...
1
vote
2answers
1k views

Wordpress Install and Database on separate hosting?

I have a situation where it would be ideal to have the database on separate hosting. Just because the host of the current site does not offer mysql. I cannot move the site (for a company) Can I ...
0
votes
0answers
20 views

How to map data on CSV to web pages?

Like Contact information, descriptions, budget, prices, other numbers, on a CSV or spreadsheet, how to link it to WordPress web page? I'm using cpanel, WordPress, Tablepress plugin, elementor page ...
0
votes
1answer
659 views

How to unserialize data from MySQL

I'm trying to unserialize data from WP's MySQL table. It looks like this my function from template-page.php <?php function get_values(){ global $wpdb; $parsed = $wpdb->...
51
votes
5answers
56k views

MySQL Database User: Which Privileges are needed?

The short installation instruction for WordPress ("5 Minutes") state that: Create a database for WordPress on your web server, as well as a MySQL user who has all privileges for accessing and ...
1
vote
1answer
171 views

Database Tables Lost Indexes? How to Recover?

I have a very interesting problem with a Multisite configuration. Two of the sites in my Network have lost their indexes in all database tables related to the sites. I cannot update these sites ...
0
votes
2answers
47 views

Wordpress post insertion from PHP file

I have a website it's contains a lot of news, i have to list this news in one PHP file , now i want to insert each news in wordPress as a Post.. what is the best practice way to do that (the news are ...
0
votes
1answer
37 views

Proper way to display latest 5 posts grouped by post type?

i need to display the latest 5 posts of each post type, something like: Latest BMW Posts: Post title BMW 1 Post title BMW 2 Latest Audi Posts: Post title Audi 1 Post title Audi 2 And so on. It ...
0
votes
1answer
23 views

Add postmeta to all blog posts

I have a bunch of blog posts that I need to update with a custom postmeta key/value pair. Therefore I have two questions - where can I find the postmeta entries in a worpdress MySQL database and how ...
1
vote
1answer
255 views

Is XAMPP faster than running LAMP in WSL on Windows 10? [closed]

I've been using Local by Flywheel for my local dev environment but recently it started acting weird so I decided, that since I'd finally learned a decent amount of CLI, maybe I should try just using ...
0
votes
1answer
18 views

Show Mysql table elements as pages in Wordpress

I am trying to build a WordPress site, but I need a specific functionality and I haven't been able to find a plugin for it. I'm going to be scraping sites info and posting the info into a DB (this is ...
0
votes
0answers
233 views

Ajax duplicate multiple inline data checking from database

I am trying to make a form with multiple same type field (i.e. title) in Wordpress. In that case I need to ensure that no duplicate data is being attempted to insert before the form is submitted. I ...
2
votes
0answers
108 views

$wpdb->get_results() does not fetch results with unicode 'WHERE' clause

I've just a simple query to fetch a students records by his name, written in Bengali. $student_rcrd = $wpdb->get_results("SELECT * FROM student WHERE name='আবুল কালাম আজাদ'"); Although my database ...
1
vote
4answers
18k views

Convert WordPress posts to products in WooCommerce

Is there anyway I could convert all the posts e have right now on our WordPress install into products using some MySQL query or something like that?
2
votes
1answer
772 views

Move value of one custom field to another

I've one custom field named as "video" and I want to copy the custom field value to my another custom field named as "theme2035_embed." I could do it manually, but since I have more than 2500 posts ...
0
votes
1answer
20 views

How To Upload Existing WordPress Site To WordPress Multisite Using SSH

I have a WordPress site that needs to move into a WordPress Multisite. I tried to find the site file to upload in wp-content/uploads/sites but I couldn't locate the file. I also tried to upload the ...
1
vote
2answers
3k views

“#1067 - Invalid default value for 'post_date'” when trying to reset AI after backup

I've restored my Wordpress database from an sql backup. However, in doing so, all of the tables have lost auto increment. When I try to add it back in with this sql ALTER TABLE `mercury_posts` ...
0
votes
0answers
80 views

Create WordPress shortcode from database entries

So I want to create a shortcode for every row in my database. The problem here is that the add_shortcode() requires a shortcode, which I can create a variable for in a foreach loop and a callback ...
0
votes
1answer
150 views

How to use mysql LIKE with wpdb?

as per title I need to use LIKE operator to delete a row on db programmatically with $wpdb. I wanna use $wpdb->delete to remove an occurrency but I don't know how to set the LIKE operator because ...
-1
votes
1answer
144 views

Query Concatenation

I can't figure out how to properly concatenate my PHP variables in my MySQL query. $convert_class_id and $convert_char_id are holding numerical values. When I try to activate my plugin I get an ...
-1
votes
1answer
27 views

Get all the related data from WordPress DB

I have 2 custom tables inside the DB WordPress is installed in, With one-to-many relation between both tables. Here are the two tables: posts table ...
1
vote
0answers
18 views

Update results, Before deleting the related category [closed]

There is a DB that contains 2 tables posts and categories, Each category could contain many posts, So I'm using one-to-many relation between the two tables. Using the id of the categories and a ...
2
votes
2answers
353 views

How to make WordPress plugin check for database changes and then do something?

How do I for instance check if there is written a new comment in the database and then make my plugin register that there have been a change? I will use this information to do something in the ...
0
votes
3answers
2k views

Can't find my wordpress DB in phpmyadmin

I have created a a site on my localhost, But Now I need to upload website on live server so i need to export word press DB from Phpmyadmin, But I cant find any WP DB there. Here is my wp-config file ...
1
vote
1answer
74 views

Converting MYSQL to WordPress $WPDB

I’m upgrading an archaic Wordpress site from 3.7. It has some SQL query requests that don’t function after 3.9+ where you now have to connect to the DB via $WPDB (https://codex.wordpress.org/...
1
vote
1answer
86 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 ...
0
votes
0answers
44 views

How can I verify WordPress nonce from the following code?

<?php /** * Template Name: Manage Days */ if ( isset($_GET['remove_date']) && isset($_GET['_wpnonce']) ) { $delete_date = $_GET['remove_date']; $delete_nonce = $_GET['_wpnonce']; ...