save new data to wp_options non-post form

Load the existing option first and save the new data as an element in an array: // get the option $data = get_option( ‘row_name’ ); // add new data to the option $data[] = $options; // save it back to the db update_option( ‘row_name’, $data ); Your option will then be an array of arrays … Read more

Updating User Meta with SQL Query

How can I write a bulk MySQL command to add in the value wp_capabilites=”a:1:{s:10:”subscriber”;b:1;}” into each user_id except 1, 2 and 3 ie. the newly imported users? You don’t. That is a serialized array which is a PHP construct. MySQL has no idea what to do with it. To the database, it is just an … Read more

Long option names fail silently?

You don’t get an error because WordPress does not check for the length, and MySQL silently truncates it (giving a warning, not an error), unless you enable the STRICT_ALL_TABLES option (which will change the warning into an error). Even more confusing, when you enable multisite the options are saved in the sitemeta table with a … Read more

How do I move a WordPress site to another server?

I do this all the time to move a site from our staging server to the live domain. I use PHPMyAdmin to export the database as an SQL file, then open it up in a text editor and do a global find and replace on the old url to change it to the new url. … Read more

Accessing two databases

You can easily set up another $wpdb object to access your other database. $mydb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); var_dump($mydb); That, of course, uses the default connection credentials but if you defined different constants and used those, is should work just fine. If this other database is not a WordPress database, you won’t have … Read more

wpdb Custom Meta Data with 2 conditions

I found my error in the above query. There still may be a better way to do this, thank you kaiser, and I will update once I’ve done more study. What I forgot to do was GROUP_CONCAT another meta_value so i could pull out different bits. It still seems longer than it needs to be, … Read more

Multiple WP install with same users database

You can do the sharing of users fairly easily. Basically, both sites would use the same database (set up in wp-config.php), but each would get it’s own, unique $table_prefix. From there, you can specify custom user and user meta tables that are the same for each site. <?php // site 1 wp-config.php $table_prefix = ‘site1_’; … 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.

Fulltext search in posts sorted by relevancy

You may want to check the Sphinx search engine http://sphinxsearch.com/ It took me about one day to set it up and learn how to use, but it does really good job with sorting by relevancy and grammar stemming. Also it is faster than fulltext search for big data sets thanks to indexing.