Skip to content

Instantly share code, notes, and snippets.

@marcinzaremba
Created May 29, 2013 21:35
Show Gist options
  • Save marcinzaremba/5674016 to your computer and use it in GitHub Desktop.
Save marcinzaremba/5674016 to your computer and use it in GitHub Desktop.
Load categories colors in advance to avoid
/**
* load_categories_colors
*
* Load categories colors in advance to avoid
* multiple queries
* @author Marcin Zaremba
*/
function load_categories_colors() {
$cats = get_categories();
$ids = array();
foreach($cats as $cat) {
$ids[] = $cat->term_id;
}
update_termsmeta_cache($ids);
}
add_action('plugins_loaded', 'load_categories_colors');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment