简体   繁体   中英

Get Category in Wordpress Post

OK I have a standard post here:

http://www.ticketyoda.co.uk/concerts/rihanna-tickets/rihanna-tickets-manchester-2013-06-12-united-kingdom/970

I am trying to make each post unique and contain the category information for both the city (Manchester) and the Artist (Rihanna).

At the moment the box underneath the venue contains the information taken from the category (see breadcrumb). So I have 1 out of 2. What I need now is for an extra box below to show the category information for the Artist.

I use : <?php $category = get_the_category(); echo $category[0]->category_description; ?> <?php $category = get_the_category(); echo $category[0]->category_description; ?>

to get the first category.

You can see the rihanna description under the posts here:

http://www.ticketyoda.co.uk/concerts/rihanna-tickets/

Any help appreciated.

I think the reason you are only getting one category is due to your echo statement. It only calls for 1 value $category[0], in order to get a second category try [1]. Out of curiosity is the second category a child of the first?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM