Inside of your loop you can get the terms via wp_get_post_terms
function. Then, check if two or more terms exist. If they do, then use the function array_slice
to extract the second term that appears in the array:
$term_list = wp_get_post_terms( $post->ID, 'YOUR_TAXONOMY', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all') );
$display_term = (count($term_list) > 1) ? array_slice($array, 1, 1) : $term_list;
However, this does not determine how the terms will output from the database. You may want to define the orderby
parameter to be something specific so you can predict which term will appear second.
Sources:
Related Posts:
- How to display by default only published posts/pages in the admin area?
- Find out who deleted a page or post?
- Post/Page Preview Template
- using wp_update_post on save_post
- Replace image attributes for lazyload plugin (data-src)
- Exclude drafts in all() view of edit.php
- WordPress plugin to publish to multiple remote WordPress blogs
- Any way to create a revision of a post ONLY with a new button in the Meta Box?
- How to display comments and comment form on custom post type?
- Prevent duplicate posts in wp_insert_post using custom fields
- Add default content to post (for specific category)
- How to wrap every image in a post with a div?
- Show One Category on Post
- WordPress Delete hook with wp_delete_post function?
- Custom post type single (permalink) throws a 404 error
- Order post by year DESC and month ASC
- Do I use custom post type or something else?
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- Delete Post From Front-End and attachment permanently
- same template for multiple custom post type single
- if custom post type exist
- How to place HTML below the title of the (custom) post overview
- Custom post type permalinks breaking due to 3.1 bug fix
- ‘Invalid post type’ error when importing from one site to another
- .current-menu-item class on custom post type children pages – again?
- Blogroll – Different layout for first post
- How to delete old posts’ edits to save space?
- Get post id in wordpress action?
- Run a function when post is deleted?
- Remove slashes (both before and after) in relative post url
- Animated gif for a thumbs
- Edit custom post type admin menu link
- I am unable to publish/update post
- How to include a post type in the admin/backend?
- Get posts of ONE taxonomy term of custom post type
- WordPress Custom Fields (Checkboxes with multiple values)
- How to make number of blog posts a custom field?
- WordPress blog or WordPress website
- Using custom post template
- Custom Post Archive Page not working
- Hiding Draft Post In Admin
- Adding custom fields to bbpress reply form
- Adding buttons to Add New Post and Add New Page
- Making a custom Pagination for multi page blog post
- Permission issue with custom post type – not added to menu – by plugin
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- Thumbnail & Category link aside post
- Custom post types related to same custom post type?
- Is it possible to customize the post according to post format in single.php?
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- WordPress custom post type with folder structure in slug
- Check if a custom post type has already been created
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- Show custom post with custom categories with specific slug
- Querying another post category to match current post and display in loop
- datepicker value in mysql
- Simple Custom Metabox Not Saving
- Change default post style to columns
- Custom Post Type, post-formats associated to custom post type > 404 archives
- How to restore deleted post related with deleted users
- Custom Post Type Single Loop Outputting Wrong Post
- Organization of time insensitive content
- How to output all taxonomy links from a custom post type in a menu?
- Can I style single post that are in multiple catergories?
- WordPress Post Deletion Issue
- How Can I Always Display A Particular Post First Using WP_Query?
- What would causes search to return incorrect results?
- MySQL: Possible to replace all of wp_posts.post_content(id#) via UPDATE + REPLACE + SELECT?
- Change modified date to current date when title updated automatically
- How to put the author of the post in the comments?
- How to add a custom class attribute into code wrapper? [duplicate]
- Redirecting wordpress search query to archive page
- Tag for custom post type
- How to create custom search form function including post “tags”
- How to invoke a HTML custom button based on a HTML dropdownlist menu
- Please I want to prefix my WP posts title according to each category
- insert post fails after multiple postings
- Custom Post Type Rewrite URL
- Custom Post Types and Broken Permalinks
- The first post appears twice
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- Append a random string to a post permalink
- Show Posts By Custom Field
- Custom Post Type doesn’t use single.php or single-{custom_post_type}.php
- How to retrieve custom field values and save again as array
- How to list all names and descriptions of a custom taxonomy
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- Customize search results to include custom posts and display in a specific template page
- Custom permalink based on custom post type fields
- Checking if some condition is matched before inserting post into database
- How to only allow post to be deleted if custom field doesn’t exist
- Special Query: Title, Terms, Content – %LIKE%
- Custom Post Title as search term
- adding custom meta as well as looping through posts
- Best way to enable sorting by 3 criteria on a page of listings
- WordPress 3.2 – Problem with WYSIWYG editors in a custom post type?
- How remove “recent comments” title without modifying code? [closed]
- How edit footer copyright info? [closed]
- Dynamic Menu Item
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields