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 :: array_key_exists 
Php :: get request data in observer laravel 
Php :: square root php 
Php :: get domain url with https in laravel 
Php :: download pdf php 
Php :: laravel auth 6 
Php :: php remove space from string 
Php :: laravel validation greater than or equal to 
Php :: how to create slug in laravel 
Php :: compare php date with mysql date 
Php :: PHP Time Limit: 
Php :: date time laravel 
Php :: php delete directory 
Php :: how unique field in table in phpmyadmin 
Php :: check null in_array php 
Php :: contains php 
Php :: laravel wherein example 
Php :: php get day of week 
Php :: how to add javascript in php 
Php :: jwt auth laravel auth without password field 
Php :: Add WooCommerce Price Suffix 
Php :: laravel query builder get last insert id 
Php :: Laravel Retrieve All Session Data 
Php :: array of dates laravel 
Php :: join array of strings php 
Php :: php object 
Php :: Call to a member function move() on string 
Php :: redirect back laravel 
Php :: laravel migration delete column 
Php :: unset php 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =