Skip to content

Instantly share code, notes, and snippets.

@junaidtk
Created October 23, 2018 16:55
Show Gist options
  • Save junaidtk/bb9ab3b3936c80f3d7faa5dfbb9582e5 to your computer and use it in GitHub Desktop.
Save junaidtk/bb9ab3b3936c80f3d7faa5dfbb9582e5 to your computer and use it in GitHub Desktop.
Get the terms of a POST with ID
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