WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. pomponian
    Member
    Posted 1 year 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(); ?>
            </a>
        </li>
    <?php endwhile; ?>
    <?php else: ?>
        <li>No Case Studies found</li>
    <?php endif; ?>

    Any help would be greatly appreciated!

    Many thanks

  2. LIMEXS
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    Awesome, works great thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic