Answers for "custom post type category in wordpress"

0

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>' . ' ';
       }
  ?>
Posted by: Guest on December-21-2021
1

wordpress custom post type Query

<?php 
    query_posts(array( 
        'post_type' => 'portfolio',
        'showposts' => 10 
    ) );  
?>
<?php while (have_posts()) : the_post(); ?>
        <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?>
Posted by: Guest on June-07-2021

Code answers related to "custom post type category in wordpress"

Browse Popular Code Answers by Language