Put this in your loop:
<?php
$title = get_the_title();
$posttags = get_the_tags();
if( $title && $posttags ) {
$result = find_tag_in_title( $title, $posttags );
var_dump( $result ); // dump result
}
?>
Put this in your functions.php file:
<?php
function find_tag_in_title( $title, $posttags ) {
foreach( $posttags as $tag ){
if( strpos( strtolower($title), strtolower($tag->name) ) !== false ) return $tag->name;
}
return false;
}
?>
Related Posts:
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
- WP_Query use for a filter with multiple Taxonomies and Terms
- Duplicates with WP_Query loop
- Display related products with custom output
- How do I dynamically generate args for wp_query?
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- Can’t search posts using WP_QUERY inside AJAX Function
- How can I use wp_query to show all product data using just the products ID?
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Custom page archive query by url var calling page twice on one of my custom queries?
- How to query for posts with a null or blank post_name?
- WordPress pagination not working with search page
- WP Query with custom Shortcode
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- How to use an associative array in post__in with WP_Query?
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Add more button if more 8 items
- How to store post ID’s in cookie or session to display the same posts later
- WordPress, AJAX and pre_get_posts using conditional tags
- Exclude posts based on meta value
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- auto-populating custom nav with all items from custom post type
- Remove echo from shortcode
- WordPress theme options error
- Get posts from multiple post type
- WP_Query fails despite having 1 post
- unable to use ‘new WP_Query’ in AJAX call
- wp_query get the 2nd post
- How to add div blocks after certain set of post
- the_posts_pagination() not working in wpquery
- WP_Query: getting posts where custom field exists
- Convert a string into a decimal number for use in query
- Increment paged on WP_Query
- Hide posts if user is added to it WP_query
- Custom route and query
- Getting posts to exclude from array
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Custom post type permalinks do not appear using the link functions
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Modify main query before it run without pre_get_post
- WordPress WP_Query without query GET parameters
- Sort posts in a specific way
- array_rand not working correctly?
- WP_Query() load selected post
- posts_nav_link pulling in multiple post types
- displaying a fall back query if there’s nothing in the post-type category
- Modifying WP URL handing code?
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- WP_Query: How to get results from both meta_key options?
- Free search and custom taxonomy query not providing the same result
- How do I reset $wp_query in a function?
- Output product category link from WP_Query
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- wp_query with multiple arguments with AND
- Passing in MySQL prepare statement parameter separately throwing error
- Replace a single variable with add_filter
- Nested Queries of decreasing specificity
- Wrong pagination results, page counter resets when navigating
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- Sending simple variable on single page to WP JSON
- How to exclude meta no index pages from wp_list_pages
- in_array not working on dev server but works on localhost
- meta_query search names when they have middle initials
- Custom search query on WordPress page not working
- WP query posts BUT show the most recent and one per author
- Define global custom post
- posts_per_page displays only 2 posts instead of 4 posts
- get_filtered_term_product_counts – Get product terms if any products
- Need to show 7 posts from actual date
- Search for single post by 2 tags
- Paged WP_Query is quitting on page 3
- Get Child of Child Pages in custom Menu
- List all ACF field values across every post on one page
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- Query to show average # of months all accounts with specific role have been active
- Woocommerce Related Product by 2 taxonomy
- Query doesn’t display text data with apostrophes
- Querying posts from wordpress with 2 or more conditionals
- Efficient way of querying for a “fallback” post?
- SQL Query Search page
- Can’t get data from audio media
- Create a hierarchical loop at predefined markup requirements
- Display Year and Month from custom field + Age Calculator
- insert thumbnail image from php script
- WP_Query count of different meta key values [duplicate]
- Masonry layout within the loop
- Query seems to be duplicated
- Keeping the previous get value and add another value when submitted
- Fix incorrect related posts code snippet
- wp_query on search results page showing all results every time
- How do I run the following script from my articles page?
- Execute multiple PHP Snippets causes error?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Three different queries on same page
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404
- How to sort search result by post_title, then by post_content
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress