Created
January 5, 2017 15:12
-
-
Save sachyya/077f2a0567afeac59690024fff011dc9 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
<?php | |
/** | |
* Get term link | |
* @param string $term_slug Term slug | |
* @param string $taxonomy Taxonomy slug | |
* @return string Term link | |
*/ | |
function prefix_get_term_link( $term_slug, $taxonomy ) { | |
// Check if the term exists | |
$term = term_exists( $term_slug, $taxonomy ); | |
if ( $term !== 0 && $term !== null ) : | |
$term_id = (int)$term['term_id']; | |
return get_term_link( $term_id, $taxonomy ); | |
else : | |
__return_null(); | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment