Skip to content

Instantly share code, notes, and snippets.

View BicanMarianValeriu's full-sized avatar
💭
I may be slow to respond.

Vali BicanMarianValeriu

💭
I may be slow to respond.
View GitHub Profile
/**
* Get primary taxonomy term (YoastSEO).
*
* @param mixed $taxonomy Taxonomy to check for.
* @param boolean $term_as_obj Whether to return an object or the term name.
* @param int $post_id Post ID.
* @return mixed The primary term.
*/
function get_primary_tax_term( $post_id = 0, $taxonomy = 'category', $term_as_obj = true ) {
if ( 0 === $post_id ) {