Pages

wordpress insert meta key and value query

Wednesday, 22 January 2014

wordpress insert meta key and value query
wordpress insert meta key and value query

$metakey = "_metakey";
$metavalue = $metakey_val;
$post_id= $post_id;
$wpdb->query( $wpdb->prepare( 
"
INSERT INTO $wpdb->postmeta
( post_id, meta_key, meta_value )
VALUES ( %d, %s, %s )
", 
        $post_id, 
$metakey, 
$metavalue 
) );
 

Most Reading