Don’t use get_the_term_list()
as it returns an HTML string, which makes comparing more difficult.
Use wp_get_post_terms()
(Codex link) instead. It can return an array, and then you can use something like array_intersect()
to get the terms that match.
Your code should look something like this (I haven’t tested this):
$course_terms = wp_get_post_terms($course_post_id, 'course_type'. array('fields'=>'slug'));
$testimonial_terms = wp_get_post_terms($testimonial_post_id, 'course_type'. array('fields'=>'slug'));
$matches = array_intersect($course_terms, $testimonial_terms);
if (count($matches) > 0) echo "matching terms";
Related Posts:
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Control content before and after custom post type loop
- Combine multiple separate lists into one
- Show parent category and subcategory once in while loop
- Add active class to foundation 6 tabs while looping categories
- WordPress query posts by custom post type not workng
- WordPress Custom Post Type and sort by Tags
- Order by custom field attribute
- Looping taxonomy in taxonomy?
- Display all posts in a custom post type, grouped by a custom taxonomy
- Ajax filter with custom taxonomies
- List events by month
- Conditional two level dropdown filter for custom post type
- Show all custom post type posts sorted by custom taxonomy then by another custom taxonomy
- Custom post type loops with different page templates
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- 404 error PageNavi custom type taxonomy | wordpress
- Query for posts in 2 taxonomies
- How do you output custom code between posts in the loop?
- Show ACF field from custom taxonomy and display on the single template
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- wp_query to find posts by year and month
- Custom Post Type Loop within Shortcode
- Weird problem happening with custom taxonmy when creating/updating posts
- get_template_part for each level of taxonomy term
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Very Slow Page – How to Optimize # of Queries?
- Display CPT posts based on specific taxonomy
- How to display selected taxonomies by their parent
- Custom Field Order by Last Name and First Name
- WordPress Genesis custom taxonomy archive shows 3 repeats of each post
- Am unable to reset a query properly
- How to make sure content doesn’t display if selection is empty
- CPT + CMB2: data not displaying for only first post in loop
- Get next and previous 3 posts in a term in single post page
- Get custom post type list for every category shortcode
- Loop custom taxonomy to get lists of cutom post types?
- How do i calculate the total of values of custom fields in custom post types?
- Show a Category X’s custom post type on Category X archive page?
- Display all taxonomy terms, add class if term applies to current post
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- Different Category system needed for the Custom Post Type
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Trying to get custom post of a custom taxonomy
- Loop increase number
- Get data from PHP to JavaScript to set position of each post on front page
- display posts of custom post type with custom taxonomy
- When I choose category from dropdown then everything working fine.But in backend it checked only child not parent [closed]
- Query custom post types & Taxonomies and list them in a table on a page
- Custom post type and custom taxonomy 404 on page 2
- Custom Post Type and Taxonomy Loop Output Is Wrong
- Nested Custom Taxonomies | Incorrect posts when querying
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- foreach loop inside the loop creating duplicates in output
- Function to erase every post from a taxonomy
- Using page title as a link to term archive
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- How do i display post from a taxonomy term?
- Setup page template array in a custom post type
- What is the most efficient way to execute recursive complex queries?
- How do I ensure that post_type and Taxonomy use the same slug?
- How to get post count of specific taxonomy that have store name & category
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- CPT loop doesn’t seem to account for post date?
- How to display list of custom post taxonomy terms and their posts (if any)?
- Custom front-end form for adding post – Category problem
- update custom taxonomy custom fields
- Filter taxonomy by CPT
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Some posts not displaying by taxonomy term
- posts_per_page is not working by term
- Filter Custom Post Type Posts by Taxonomy
- Change Search display for Custom Post Type
- Custom search for a custom post type in WordPress
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- % encoded URL giving 404 error in WordPress
- CPT: multiple loops with different terms
- tax_query not working?
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Looping through custom taxonomy in one template
- get_post_meta for Custom Post Type ( CPT )
- Show custom taxonomy not in submenu
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- Pods pagination erases my sub menu
- Loop with Custom Post Type and Taxonomies
- Display posts from category in page
- Sorting custom post types by taxonomy (So close)
- Listing custom post type items from a couple of custom taxonomies
- posting twice from an array?
- Query Custom Post Type by Tag
- Catergory args causing loop not to show
- How do I filter a custom post type loop by a field?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT