Created
June 9, 2016 22:54
-
-
Save klebinhopk/59ea543d31703b7fdc2829f063ca5085 to your computer and use it in GitHub Desktop.
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
| $category_ids = array(); //Inicializa a array onde guardaremos os IDS | |
| $fromDB = term_exists($string['category'][$i], 'category' ); // Busca a categoria no banco. Se existir, teremos o ID dela, se não, NULL | |
| if($fromDB === NULL) // Se for NULL quer dizer que é uma categoria nova que precisa ser adicionada | |
| { | |
| $term = wp_insert_term($string['category'][$i], 'category'); // Adiciona a categoria nova no banco e guarda o ID gerado; | |
| $category_ids[] = $term['term_id']; | |
| } else { | |
| $category_ids[] = $fromDB['term_id']; // Guarda no array o ID da categoria que já existe no banco | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment