LLMS_Abstract_Generator_Posts::get_term_id( string $term_name, string $tax )

Get a WP Term ID for a term by taxonomy and term name


Description Description

Attempts to find a given term by name first to prevent duplicates during imports.


Top ↑

Parameters Parameters

$term_name

(string) (Required) Term name.

$tax

(string) (Required) Taxonomy slug.


Top ↑

Return Return

(int) The created WP_Term term_id.


Top ↑

Source Source

File: includes/abstracts/llms-abstract-generator-posts.php

		 *
		 * @since 3.7.3
		 *
		 * @param string         $post_status The default post status.
		 * @param LLMS_Generator $generator   Generator instance.
		 */
		return apply_filters( 'llms_generator_default_post_status', $this->default_post_status, $this );

	}

	/**
	 * Get a WP Term ID for a term by taxonomy and term name
	 *
	 * Attempts to find a given term by name first to prevent duplicates during imports.
	 *
	 * @since 3.3.0
	 * @since 4.7.0 Moved from `LLMS_Generator` and updated method access from `private` to `protected`.
	 *               Throws an exception in favor of returning `null` when an error is encountered.
	 *
	 * @param string $term_name Term name.
	 * @param string $tax       Taxonomy slug.
	 * @return int The created WP_Term `term_id`.
	 *
	 * @throws Exception When an error is encountered during taxonomy term creation.
	 */
	protected function get_term_id( $term_name, $tax ) {

		$term = get_term_by( 'name', $term_name, $tax, ARRAY_A );


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Moved from LLMS_Generator and updated method access from private to protected. Throws an exception in favor of returning null when an error is encountered.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.