How to get several Custom Fields?

0

How can I get the% values of% of different posts without needing insert multiple Custom Fields ?

    
asked by anonymous 24.03.2017 / 14:06

2 answers

0

You can fetch directly from the database:

global $wpdb;

$resultado = $wpdb->get_results( "SELECT id,meta_value from {$wpdb->postmeta} WHERE meta_key = 'key';" );
    
24.03.2017 / 18:22
0

Use the function:

$ custom_fields = get_post_custom ($ post-> ID);

foreach ($ custom_fields as $ key = > $ value) {

echo $key . " => " . $value . "<br />";

}

    
07.04.2017 / 14:14