php - Custom Select Query by meta key and cat id -
i have custom query expiry date of post , orders post that. how amend list category id e.g. '20'
$querystr = " select wposts.* $wpdb->posts wposts, $wpdb->postmeta wpostmeta wposts.id = wpostmeta.post_id , wpostmeta.meta_key = 'es_ape_expiry' order wpostmeta.meta_value asc "; $pageposts = $wpdb->get_results($querystr, object);
many !
try next query , replace $cat_id 20
select wposts.* $wpdb->posts wposts, $wpdb->postmeta wpostmeta bring together $wpdb->term_relationships tr on (p.id = tr.object_id) bring together $wpdb->term_taxonomy tt on (tr.term_taxonomy_id = tt.term_taxonomy_id) bring together $wpdb->terms t on (tt.term_id = t.term_id) wposts.id = wpostmeta.post_id , wpostmeta.meta_key = 'es_ape_expiry' , tt.taxonomy = 'category' , t.term_id = $cat_id order wpostmeta.meta_value asc
php sql wordpress codex
No comments:
Post a Comment