Get taxonomy terms of current post using certain taxonomy (3 posts)

  1. pomponian
    Posted 3 years ago #

    have the following code, and basically want it to display the term's slug in the data-type="HERE" part. This is on a static html page outside of the wordpress installation.

    I have it displaying the custom post types as a list, but can't get it to display the terms from the taxonomy of 'categories'.

    <?php $args = array( 'post_type' => 'case_study' ); ?>
    <?php require($_SERVER['DOCUMENT_ROOT'] . '/news/wp-load.php'); query_posts($args );  if (have_posts()) : while (have_posts()) : the_post(); ?>
        <li data-id="id-<?php the_ID(); ?>" data-type="DISPLAY TAXONOMY OF CATERGORIES TERMS HERE">
            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                <?php the_post_thumbnail('case-study-thumb'); ?>
                <?php the_title(); ?>
    <?php endwhile; ?>
    <?php else: ?>
        <li>No Case Studies found</li>
    <?php endif; ?>

    Any help would be greatly appreciated!

    Many thanks

    Posted 3 years ago #

    please, use wp_get_post_terms( $post_id, $taxonomy, $args )

    where $taxonomy is current post's taxonomy name. this is not always categories. Please, make sure the name of taxonomies for that post.

  3. pomponian
    Posted 3 years ago #

    Awesome, works great thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic