Created
December 8, 2014 23:52
-
-
Save sidharrell/203414222d119d77b971 to your computer and use it in GitHub Desktop.
Insert category relations in EE4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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