WooCommerce sku location in DB

As suggested in comments, the best way to update stock, or any other product information would be through the WooCommerce API. The product endpoint with all the parameters is documented here (link is directly to how to update): https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product. I’m not very familiar with woocommerce, but based on other posts it looks like the stock … Read more

Help running a MySQL query to update all wp_#_options tables in a Multisite install

Got a partial solution, but requires VPS to run it as shared hosting has a restriction on what you can do with a cursor. Anyway, DROP PROCEDURE IF EXISTS `update_all_options`; DELIMITER // CREATE PROCEDURE update_all_options( IN db varchar(255), IN theoption varchar(255), IN set_val VARCHAR(255) ) BEGIN DECLARE table_val VARCHAR(255); — Declare variables used just for … Read more

Tons of Twitter rows in my database

Here is a bait-and-switch approach to deleting all those rows: CREATE TABLE wp_posts_new LIKE wp_posts; ALTER TABLE wp_posts_new DISABLE KEYS; INSERT INTO wp_posts_new SELECT * FROM wp_posts WHERE post_type’http’ AND post_title<>’GET http://twitter.com/statuses/user_timeline/@xcentric.json?count=100′; ALTER TABLE wp_posts_new ENABLE KEYS; ALTER TABLE wp_posts RENAME wp_posts_old; ALTER TABLE wp_posts_new RENAME wp_posts; Now start using you website. When you are … Read more

I have a table I created, how do I make a form for a user to filter the data?

Here is the html: <form name=”filter” action=”<?php echo str_replace( ‘%7E’, ‘~’, $_SERVER[‘REQUEST_URI’]); ?>” method=”post”> <input type=”hidden” name=”filter_submit” value=”Y”> <select name=”your_filter” class=”input”> <option value=”none”>nothing selected</option> <option value=”b”>b</option> <option value=”c”>c</option> </select> <input type=”submit” name=”submit” class=”input” value=”Filter” /> </form> Here is the php to filter data: function filter() { global $wpdb; $table_name = $wpdb->prefix . “your_table_listings”; $sql = … Read more

Clean database from unused tables

Backup your Database and then use DROP statements to delete the tables manually via tools such as MySQL Workbench, or MySQL Query Bench. There are many alternatives you can use that provide GUIs for backuping up, restoring, and modifying DBs. Here’s the WordPress DB schema, do not delete any of these tables: http://codex.wordpress.org/Database_Description Aside from … Read more

How to log database changes during an upgrade?

Why would you need to log them? They’re defined in the code itself. Look at wp-admin/includes/upgrade.php. Every version that changes the DB has a function defined that does the job. The changes made for version 3.4 are defined in the upgrade_340() function. The changes made for 3.3 are defined in the upgrade_330() function. And so … Read more

wp_admin edit.php slow with lots of queries

One way to do this (and yes, it is ugly and hackish) is to create a custom page having a custom page template that draws out all of your posts and creates the proper admin url links for each one. For example: <?php /* Template Name: View Posts Quickly */ if ( !is_user_logged_in() ) { … Read more