[wp-trac] [WordPress Trac] #55889: Allow specifying multiple keys as an array in meta and option retrieval functions.

WordPress Trac noreply at wordpress.org
Wed Jun 1 08:58:50 UTC 2022


#55889: Allow specifying multiple keys as an array in meta and option retrieval
functions.
--------------------------------+------------------------------
 Reporter:  namith.jawahar      |       Owner:  (none)
     Type:  feature request     |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Options, Meta APIs  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:  performance
--------------------------------+------------------------------

Comment (by knutsp):

 Hello and welcome to Trac!

 Thank you for the suggestion. Might be a good idea, or a new function
 (`multi_get_*`).

 Sure, we often need to get values of multiple keys from meta or options.
 I use

 {{{#!php
 foreach ( array('key_1, 'key_2'...) as $key ) {
     $meta_values[ $key ] = get_post_meta( $post_id, $key, true );
 }
 }}}
 Why do you think would it be more efficient to specify multiple keys in
 the function call? The number of SQL queries generated when not cached?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55889#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list