Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for recounting taxonomy terms for Products #36

Open
thomasmery opened this issue Jul 5, 2018 · 0 comments
Open

Add support for recounting taxonomy terms for Products #36

thomasmery opened this issue Jul 5, 2018 · 0 comments

Comments

@thomasmery
Copy link
Owner

thomasmery commented Jul 5, 2018

We need a way to simply recount the terms associated with the store products

and thus accurately reflect the number of products associated with a term (in the term lists for instance)

this could be accessed via a button on the plugin dashboard

the function that would perform the operation is something along the lines of :

// trying to accurately reflect the nuber of products linked to the custom taxonomies terms
function update_terms_count( $taxonomy ) {
	global $wpdb;
	// we need a list of term_taxonomy_id
	// not of term_id
	// because the terms count update function needs this
	$taxonomy_terms_ids = $wpdb->get_col("
		SELECT tt.term_taxonomy_id FROM wp_term_taxonomy AS tt WHERE tt.taxonomy IN ('$taxonomy')
	");
	wp_update_term_count_now(  $taxonomy_terms_ids, $taxonomy );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant