llms_update_util_rekey_meta( string $post_type, string $new_key, string $old_key )

Update the key of a postmeta item


Parameters Parameters

$post_type

(string) (Required) Post type.

$new_key

(string) (Required) New postmeta key.

$old_key

(string) (Required) Old postmeta key.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/functions/llms.functions.updates.php

function llms_update_util_rekey_meta( $post_type, $new_key, $old_key ) {

	global $wpdb;

	$wpdb->query(
		$wpdb->prepare(
			"UPDATE {$wpdb->prefix}postmeta AS m
		 INNER JOIN {$wpdb->prefix}posts AS p ON p.ID = m.post_ID
		 SET m.meta_key = %s
	 	 WHERE p.post_type = %s AND m.meta_key = %s;",
			array( $new_key, $post_type, $old_key )
		)
	); // no-cache ok.

}


Top ↑

Changelog Changelog

Changelog
Version Description
3.4.3 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.