Skip to content

Instantly share code, notes, and snippets.

@aliciaduffy
Created November 6, 2019 19:43
Show Gist options
  • Save aliciaduffy/5e680adfc14ea8895276a2c70f83ee2a to your computer and use it in GitHub Desktop.
Save aliciaduffy/5e680adfc14ea8895276a2c70f83ee2a to your computer and use it in GitHub Desktop.
$taxonomy = get_term( $category_id )->taxonomy;
// get all post IDs within selected category
$posts_in_category = new WP_Query( array(
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'terms' => $category_id,
),
)
) );
foreach( $posts_in_category->posts as $cat_post ) {
// get total votes for each post in category - update their postmeta
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment