Multisite Support for Site Metadata in WordPress 5.1

Advertisement

Quick Highlights: Quick Highlights:

  • WordPress multisite introduces a new database table wp_blogmeta to store metadata associated with sites. This allows for the storage of arbitrary site data relevant in a multisite/network context.

  • It provides an alternative to using options and can be retrieved from multiple sites in a more performant way—without calling  switch_to_blog(). Sites can now also be queried by their meta with parameters supported by WP_Meta_Query.

  • Note: A network update is required to install the new database table.

  • New API functions:
get_site_meta( $id, $meta_key, $single )
update_site_meta( $id, $meta_key, $meta_value, $prev_value )
add_site_meta( $id, $meta_key, $meta_value, $unique )
delete_site_meta( $id, $meta_key, $meta_value )

All of these functions are ONLY available in multisite, however they work similarly to other metadata wrapper functions, such as for posts, terms, comments and users. In addition to these functions, it is now possible to use the common meta query arguments when querying sites with  WP_Site_Query or its wrapper  get_sites().


Read more at https://make.wordpress.org/core/2019/01/28/multisite-support-for-site-metadata-in-5-1/

Leave a Reply