SQL to order by CPT results by user->display_name w/only user->ID known

If I’m understanding your question correctly, I think you just want to sort your custom column by author, since by default this will sort by the ID. Untested, but can’t see why it wouldn’t work. The display value of the column shouldn’t matter. add_action( ‘pre_get_posts’, ‘wpse_orderby_author_column’ ); function wpse_orderby_author_column( $query ) { if( ! is_admin() … Read more

Automatic switch to backup database on fail

HyperDB is awesome. You shouldn’t worry about its dev date (which by the way, its being done by Automattic – the team behind WordPress). HyperDB has some bigger advantages like spreading read/writes across servers and splitting them and its mostly used for such purposes (bigger scales). In your case, I would go for a VIP … Read more

How to import a custom MySQL DB table into a WordPress custom post type

WordPress Posts are not stored in a single table. Postmeta is stored elsewhere, and of course each table has its own format. If you ever publish content directly in WordPress (posts, pages, attachments, etc.) you could quickly run into issues with post IDs. Even if not, it would potentially require some fairly significant data manipulation … Read more

#1115 – Unknown character set: ‘utf8mb4’

WordPress does not support MySQL 4 : To run WordPress your host just needs a couple of things: MySQL version 5.0 or greater (recommended: MySQL 5.5 or greater) https://wordpress.org/about/requirements/ While the utf8mb4 encoding is recent change and you might work around it, overall you still need compatible MySQL version.

Refresh table data with Ajax

In wordpress you need to use ajax in a specific way to follow the standard https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action) create a function in your functions.php file to handle the data retrieval and/or display of the table and add a hook to wp_ajax_(fires only for logged in users) and wp_ajax_nopriv_(fires for guests as well) add_action( ‘wp_ajax_add_foobar’, ‘prefix_ajax_add_foobar’ ); add_action( … Read more

Create table from array with prepare

I tried this in local, and I think you have multiple fields inside $fields so I’ve added them in array. Just look at the code below; it works fine as tested: add_action(‘your_hook’, ‘createTableFromFields’); function createTableFromFields($tablename) { $wpdb = $this->db; $tablename = $wpdb->prefix . $tablename; $fields = array(‘PersonID’,’LastName’); $sql=”CREATE TABLE IF NOT EXISTS %s (id INT(6) … Read more