Hot answers tagged

2

Q1 Yes, you can store serialized arrays as a single meta key, eg: update_post_meta( $post_id, 'my_items', array( 1, 2, 3, 4 ); Furthermore, you can store multiple values against a single meta key, eg: add_post_meta( $post_id, 'my_items', 1 ); add_post_meta( $post_id, 'my_items', 2 ); The latter is preferred because meta queries can be more efficiently ...


1

This is how meta_key/_values work. How you store your values is case sensitive. Example meta_key = 'foo' and meta_value = 'Bar' Would return the result you are looking for: $posts = new WP_Query( 'post_type=post&meta_key=foo&meta_value=Bar' ); Would not return the result you are looking for: $posts = new WP_Query( 'post_type=post&meta_key=...


1

Inserting boolean term meta values When we add non-existent term meta with e.g. add_term_meta( 123, 'test', true ); then we are actually running the following insert : $wpdb->insert( 'wp_termmeta', array( 'term_id' => 123, 'meta_key' => 'test', 'meta_value' => true ) ); within the general add_metadata() function. Now wpdb::insert(...



Only top voted, non community-wiki answers of a minimum length are eligible