Tag Info

Hot answers tagged

2

Try this, should get you started.. (not tested though) function count_total_vote() { $args = array( 'post_type' => 'post', // Your post type 'status' => 'publish', 'meta_key' => 'vote', // Meta Key ); $total = 0; $votes = new WP_Query( $args ); if ( $votes->have_posts() ) { while ( ...


1

There may not be a need for a custom query, but I'd recommend it rather than hitting the database: - once for the WP_Query - once more for each post entry And then manually working out the math in PHP. Do it all at once with one MySQL statement. select sum(PM.meta_value) from wp_postmeta PM join wp_posts P on P.ID = PM.post_id where P.post_type='page' ...


1

First option: Creating custom taxonomy and then save domain as terms. Basically "taxonomy" is a grouping mechanism. In your requiremnt there would not be too many CPTs are of same taxonomy. For Taxonomy, you have to maintain 3 tables, wp_terms, wp_term_taxonomy and wp_term_relationships. So, while creating a NEWS (your CPT), you will fire queries on these ...



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