Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Created December 8, 2014 23:52
Show Gist options
  • Select an option

  • Save sidharrell/203414222d119d77b971 to your computer and use it in GitHub Desktop.

Select an option

Save sidharrell/203414222d119d77b971 to your computer and use it in GitHub Desktop.
Insert category relations in EE4
global $wpdb;
$cat_id = 7;
$event_ids = array( 1, 2, 3, 4, 5);
foreach ($event_ids as $event_id) {
$wpdb->insert(
'wp_term_relationships',
array(
'object_id' => $event_id,
'term_taxonomy_id' => $cat_id,
'term_order' => 0
),
array(
'%d',
'%d',
'%d'
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment