Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Generator::add_course_terms( obj $course_id, array $raw_terms )
Add taxonomy terms to a course
Description Description
Parameters Parameters
- $course_id
-
(obj) (Required) WP Post ID of a Course
- $raw_terms
-
(array) (Required) array of raw term arrays
Source Source
File: includes/class.llms.generator.php
private function add_course_terms( $course_id, $raw_terms ) { $taxes = array( 'course_cat' => 'categories', 'course_difficulty' => 'difficulty', 'course_tag' => 'tags', 'course_track' => 'tracks', ); foreach ( $taxes as $tax => $key ) { if ( ! empty( $raw_terms[ $key ] ) && is_array( $raw_terms[ $key ] ) ) { // we can only have one difficulty at a time $append = ( 'difficulty' === $key ) ? false : true; $terms = array(); // find term id or create it foreach ( $raw_terms[ $key ] as $term_name ) { if ( empty( $term_name ) ) { continue; } $term_id = $this->get_term_id( $term_name, $tax ); if ( $term_id ) { $terms[] = $term_id; } } wp_set_post_terms( $course_id, $terms, $tax, $append ); } } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.3.0 | Introduced. |