• 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(); ?>
            </a>
        </li>
    <?php endwhile; ?>
    <?php else: ?>
        <li>No Case Studies found</li>
    <?php endif; ?>

    Any help would be greatly appreciated!

    Many thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    Thread Starter pomponian

    (@pomponian)

    Awesome, works great thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get taxonomy terms of current post using certain taxonomy’ is closed to new replies.