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
- don’t publish custom post type post if a meta data field isn’t valid
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- add_rewrite_rule and custom variable
- Add extra parameters after permalink?
- How do I check if a posts status is set to draft or pending?
- Output the content of a term organised by each of the CPT?
- How to get all posts except for one post from a certain custom post type?
- List children on child post
- Restrict custom post type from appearing with ?post_types=
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- Shortcode not working with post counter
- Help With Warning on creating new Post types?
- Including link to custom post type in ‘wp_list_pages’ function
- Add arguments to get_the_terms for custom post types
- Showing custom post type categories in the menu
- Stores category posts in an array
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- How to export custom post type with ACF to individual file with automation?
- Custom Taxonomy Terms in Menu lead to which page?
- Display post from custom post type
- Custom post type title of each author in his own post
- Custom Posttype URL
- Display custom post front end filter by ACF equals current user
- WordPress next post by ajax call on button click
- Custom Post By Category
- Change Custom Post Type to Post + Category
- Get post from Category by Priority
- Selecting which pages to display custom post type on using checkbox
- Custom Post Type children and grand-children in one list