Ciao,
ho questa funzione che fa il suo dovere, ossia, visualizza un singolo post per autore, ordinandoli per un custom field.
Il problema è che la query è lentissima ed alcune volte mi va in timeout.
Volevo chiedere se si poteva migliorare per velocizzarla o alternative valide per ottenere una serie di post come da oggetto.
function filter_where($where = '') {
global $wpdb;
$where .= " AND wp_posts.id = (SELECT id FROM {$wpdb->prefix}posts p2,
{$wpdb->prefix}postmeta pm where pm.post_id = p2.ID
AND pm.meta_key = 'chiave'
AND p2.post_status = 'publish'
AND p2.post_author = {$wpdb->prefix}posts.post_author
ORDER BY pm.meta_value DESC Limit 0,1)";
return $where;
}
add_filter('posts_where', 'filter_where');
Grazie.