Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Displaying the category name of a custom post type

<?php
    $terms = wp_get_post_terms( $post->ID, 'PLACE-HERE-YOUR-TAXONOMY');
    foreach ( $terms as $term ) {
       $term_link = get_term_link( $term );
       echo '<a href="' . $term_link . '">' . $term->name . '</a>' . ' ';
       }
  ?>
Comment

Get the post category if you have a custom post_type


<?php
/* FIRST
 * Note: This function only returns results from the default “category” taxonomy. For custom taxonomies use get_the_terms().
 */
$categories = get_the_terms( $post->ID, 'taxonomy' );
// now you can view your category in array:
// using var_dump( $categories );
// or you can take all with foreach:
foreach( $categories as $category ) {
    echo $category->term_id . ', ' . $category->slug . ', ' . $category->name . '<br />';
}
Comment

PREVIOUS NEXT
Code Example
Php :: if browser url is having domain name in it check using php 
Php :: get object tyhpe php 
Php :: zero padding php 
Php :: générer des nombres aléatoires décimaux en php 
Php :: install php extensions for magento 2 
Php :: join table laravel count 
Php :: php implode keys 
Php :: php delete directory 
Php :: foreach in laravel 
Php :: php get list of filenames in diretory 
Php :: failed to open stream permission denied in php 
Php :: php value to javascript variable laravel blade 
Php :: codeigniter order_by 
Php :: change arabic number to english php 
Php :: php artisan storage:link not working 
Php :: how to remove keys in subarray php 
Php :: laravel where multiple values 
Php :: laravel logout current user 
Php :: wordpress post type template 
Php :: laravel api response json 
Php :: laravel: get last id 
Php :: laravel cache put array 
Php :: loop through php array 
Php :: pagination php mysql 
Php :: add custom attribute for validation errors laravel 
Php :: get unique array from multidimentional array by value in php 
Php :: template literals php 
Php :: json encode decode php 
Php :: php-pdo-returning-single-row 
Php :: uninstall phpstorm ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =