Presentation vs Content in WP DB-Tables

Is there a clean separation between the WP tables involved with presentation vs content? I would say “no”. There is no clean separation. There is mostly-separation. Most of your content is in the post and taxonomy tables, and most of your presentation is the options table. But you also have things like sticky post IDs … Read more

What is the correct way for plugins to create tables with special charset/collation considerations?

I think this issue is handled by WooCommerce in their plugin. It also creates its own tables and this is how they take care of Collation part. (I am referring to file class-wc-install.php of WooCommerce). They have written following code in the create_tables function global $wpdb; $collate=””; if ( $wpdb->has_cap( ‘collation’ ) ) { if … Read more

Why term_id is not indexed in wp_term_taxonomy table?

A single term can, theoretically, be present in multiple taxonomies (and have a different description in each). That’s where term_taxonomy_id comes into play, referencing a single term within a single taxonomy. In practice, WP tries to avoid that, and will create a term with the same name and a -2 (iirc) suffix on the slug … Read more

store simple data in get_option()

To recap the comment chain above: I think that’s a perfectly valid way of storing some options in the database, however, it’s good practice to prepend your option name with some unique characters pertaining to your site or something, like ‘my_simple_links’ to avoid possible collisions with other plugins and themes that add_options. Also, if you’re … Read more