you can change you code a bit :
$taxonomy = 'country';
$terms=get_the_terms($post->ID,$taxonomy);
if($terms) {
echo '<h1>Holiday ';
$total_count = count($terms);
$country_count = 1;
foreach( $terms as $termcountry ) {
if ($country_count = 1){
echo 'in '.$termcountry->name;
}else{
if ($total_count = 2){
echo ' And '.$termcountry->name;
}else{
echo ', '.$termcountry->name;
}
}
$country_count = $country_count + 1 ;
}
echo '</h1>';
}
This will output in case of one term:
<h1>Holiday in Spain</h1>
in case of two terms:
<h1>Holiday in Spain And Japan</h1>
and in case of more then two terms:
<h1>Holiday in Spain, Japan, England</h1>
hope this helps
Related Posts:
- What does this PHP function code mean? [closed]
- Restrict custom post type to only site administrator role
- Linking Two Post Types
- How to force one column layout on custom post type edit page?
- modify all posts of a category to “no comments allowed”
- How to hook get_terms() to only show count of posts that have custom meta
- Why is the »_builtin« parameter not advised in »register_post_type()« for custom post types?
- Showing current taxonomy terms
- automatically create taxonomy with same name as post title
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Custom Post Type by user
- saving custom post type data to different table in wordpress
- Query post types with multiple keys
- [Plugin: Posts 2 Posts] Changing display order of connections
- same archive template for different custom post
- Get all posts WHERE custom_field is LIKE value
- Get the post children count of a post
- How to delete all posts from a custom post type?
- Check Title Unique Or Not and If not error message and dont save
- How to filter the taxonomy terms based on another taxonomy term
- Remove All, Published and Trashed Post Views in Custom Post Type
- How to post twitter like updates on wordpress
- Show Two custom Post type and their posts on category page
- apply filters only to specific post listing without check the url parameters
- Custom post type and body_class: Remove “blog” class
- Deleting Custom Post type data using mySQL command
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Display only one post each WEEK
- Which post does a taxonomy term belongs to?
- List custom taxonomy specific to one custom post type
- Meta query for custom post type ignored in main query
- Show titles, date of all posts on single category page
- Update postmeta Parent when post_status child change
- How to include term custom meta into the custom taxonomy term permalink structure
- Allow users to create posts without logging in?
- How to sort posts in a custom post type by title in ascending order by default?
- How to Display Posts From Category Within a Custom Taxonomy?
- Custom post type menu
- YOAST SEO won’t work on custom post type archive [closed]
- Separate Content from gallery (custom post type)
- WordPress Count posts within a custom post type
- Get terms for a specfic post from multiple taxonomies in custom post type
- Custom post type tags not showing in search
- How to list posts by term (custom taxonomy)
- Custom taxonomy not saving correctly
- How set template for “custom post type” individual post
- Why is my custom post content only viewable when signed into WordPress?
- Adding specific custom fields (images) to post excerpt
- Limit posts per page depending on the size of a div?
- Display title of all custom posts from same taxonomy term on a custom post template
- Delete Post by User
- How to get all posts related to a taxonomy?
- creating a custom post template
- Filter By Term Not Working – Custom Post Type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- One Post with different content, depending on a Page
- Custom Post Type
- Custom Post Status & Taxonomies
- Display all post types together
- Using get_terms() as shortcode attribute
- Turn post into simple slideshow
- Query multiple post of which one by taxonomy
- How to make a template for a specific post of a custom post type?
- How to delete unnecessary custom post types in the UI
- How to create a job post by email parsing? [closed]
- show posts under custom post type with same autj
- How to automate the creation of advanced layout article/post
- display posts, pages and custom post types from another wordpress site
- is therer any wordpress function to retrieve a specific html element from post content
- How to develop Knowledge center in WordPress Website
- ACF – Tags not showing up in Custom Post Types
- A developer set a ‘standard format’ for my blogposts on wordpress but i need to remove it, how?
- Get rewrite slug of custom post type in template
- How to check the terms in single custom post type template
- Weird problem happening with custom taxonmy when creating/updating posts
- Exclude child pages from archive.php
- Placeholder in HTML editor text area?
- is there a way to retrieve posts that do not have a featured image assigned?
- Auto-generated posts not showing in backend (but being counted!)
- Shortcode for display posts on home page show only one post
- Find the user who initially created the post
- How can I create a custom meta box to add an mp4 video to a page?
- Need help targeting a custom post type with conditional tags
- How to get the post type from a category id?
- Displaying a custom post types custom taxonomy value?
- get_the_terms return only last term
- Delete link on single-custom.php with redirection
- How to structure a site with product variations pages?
- Notice: Undefined index: suppress_filters
- CPT: if more than X images are in post, use pagination
- How to Separate CPT From Regular Posts?
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Remove rows in the manage post/page view
- Getting rid of /my_custom_post_type/ in the single view URL
- Custom post type menu missing after 3.0b2 -> 3.1.2 upgrade
- Custom Post Type – List all attachments on Edit Screen
- How to create custom boxes with text inside?
- How to add post_type=value when editing that post type in the WordPress admin?
- get_post_meta returns empty array for terms