Created
November 15, 2017 10:42
-
-
Save BinaryMoon/885c50b21b3bf106d6acec19f8fc85d9 to your computer and use it in GitHub Desktop.
An example function showing how to convert a WordPress category id to a slug.
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 | |
function prefix_convert_category_id_to_slug( $value ) { | |
if ( is_int( $value ) ) { | |
$category = get_term( $value, 'category' ); | |
if ( is_wp_error( $category ) ) { | |
return $value; | |
} | |
$value = $category->slug; | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment