Created
October 23, 2018 16:55
-
-
Save junaidtk/bb9ab3b3936c80f3d7faa5dfbb9582e5 to your computer and use it in GitHub Desktop.
Get the terms of a POST with ID
This file contains 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
This function is used for getting the terms assinged for the post. This can bve used for the filter desing in the front like masonry | |
and isotop filtering in front end desing. | |
$terms = get_the_terms( $post->ID , array( 'taxonomy-name') ); | |
$cat_app = ''; | |
$cat_name = ''; | |
foreach ($terms as $key => $cat) { | |
$cat_app = $cat->slug.' '; | |
$cat_name = $cat->name.''; | |
} | |
The $cat_app contains catogory Slug | |
The $cat_name contains category name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment