Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:12:53+00:00 2026-06-17T16:12:53+00:00

In WordPress I want to display the term attached to a post in the

  • 0

In WordPress I want to display the term attached to a post in the taxonomy ‘chapters’].
I can get the taxonomy information for a post using

$sectiondata = wp_get_post_terms($post->ID, 'chapters', array("fields" => "all"));

Then using

print_r $sectiondata;

I can display the array of values returned.

However, how do I echo the value for the ‘name’ of the term to the page?
I thought this should be something like:

echo $sectiondata->name;

But that returns nothing so I obviously don’t understand how to extract this value from the array. I’ve searched around for examples and don’t see anything that explains how to display the value on the page, or perhaps better stated how to extract the value from the array. I’ve tried using the plain php approach of

print($sectiondata['name']);

But that doesn’t return anything either.

Where can I find an explanation of how to extract the value from the array.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:12:54+00:00Added an answer on June 17, 2026 at 4:12 pm

    The issue is you’re not looping through the array returned. Before I show you how to do this with wp_get_post_terms, have you tried using the get_terms function? I believe this may be a better approach for you:

    $terms = get_terms('chapters');
    echo '<ul>';
    foreach ($terms as $term) {
        echo '<li><a href="'.get_term_link($term->slug, 'species').'">'.$term->name.'</a></li>';
    }
    echo '</ul>';
    

    Source: http://codex.wordpress.org/Function_Reference/get_terms

    …

    If that doesn’t work for you check out how you can use wp_get_post_terms to do pretty much the same thing:

    echo "<ul>";
    $terms = wp_get_post_terms( $post->ID, 'chapters');
    foreach($terms as $term) {
        echo "<li><a href='".get_term_link($term)."' title='".$term->name."'>".$term->name."</a></li>";
    }
    echo "</ul>"; 
    

    http://codex.wordpress.org/Function_Reference/wp_get_post_terms

    I hope this helps you out! Let me know if there’s any issue with either code example above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display on my Wordpress website using MapMyFitness's API. It needs to
How can I limit query result in wordpress let's say I want to display
Simple question. I'm creating a wordpress theme and I want to display the post
I want to display a list of post titles from a custom taxonomy in
Im using wordpress to develop a site ... I want to display everything in
I want to Display Google Map into my wordpress site. I have used below
I have a WordPress installation on my site, and I want to display WP
I'm using the social connect plugin for wordpress and want to make the social
I want my Wordpress user to login and I can put their username as
I want to display total number of user who only have posts at Wordpress.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.