Customize JSON output

This code will do the job: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); $posts = array(); $categories = array(); $json = array(); while( $query->have_posts() ) : $query->the_post(); $post_categories = get_the_category(); $post_category = current($post_categories); $categories[] = array( ‘name’ => $post_category->name ); $posts[] = array( … Read more

What kind of data is that?

It’s a serialized string. Here’s a good description of what it is: A PHP array or object or other complex data structure cannot be transported or stored or otherwise used outside of a running PHP script. If you want to persist such a complex data structure beyond a single run of a script, you need … Read more

How to Create database table when Plugin installed/activated, and delete database when Plugin deleted

Use this code instead- class hidemysite_security{ public function __construct() { if (is_admin()) { register_activation_hook(__FILE__, array( $this, ‘activate’)); register_deactivation_hook( __FILE__, array( $this, ‘my_plugin_remove_database’ ) ); } } public function activate() { global $wpdb; $table = $wpdb->prefix . ‘md_things’; $charset = $wpdb->get_charset_collate(); $charset_collate = $wpdb->get_charset_collate(); $sql = “CREATE TABLE $table ( id mediumint(9) NOT NULL AUTO_INCREMENT, time … Read more

Show content from database

You could use custom post types and custom taxonomies. Using the custom post types to store data, taxonomies to categorize the data and you can utilize WordPress’ default searching functionality. https://codex.wordpress.org/Post_Types https://codex.wordpress.org/Taxonomies https://codex.wordpress.org/Creating_a_Search_Page

How to check if a core update, like 4.9.8 → 5.0, involves a database update (migration)?

So after some thinking I came up with this: Codex / WordPress Versions has Changelogs, but these seem to mention (recent) database upgrades implicitly, starting at 5.0. (Compare how Matomo explicitly states DB upgrades). Maybe this will be enough for future versions, here’s the thorough, cumbersome way that works for older versions, too: check db_version … Read more

How can I UN-orphan media files?

This is random, but a friend of mine got himself into the same situation a two weeks back and found this plugin to be helpful. https://wordpress.org/plugins/media-sync/ But as Tom mentioned above in his comment, you’ll run into attachment post type issues. Hope this helps you get half way there!!