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
- 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
- Create a Blog Template Page
- Exclude posts with specific metadata from search?
- Display an image if odd number of posts in grid
- How to add div blocks after certain set of post
- Why doesn’t PhotoSmash plugin play well with wp_query?
- the_posts_pagination() not working in wpquery
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- get_the_ID() doesnt work
- Hide posts if user is added to it WP_query
- Custom route and query
- change the default order of posts only for specific categories
- Getting posts to exclude from array
- 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
- How can I split my query result in 2 arrays?
- array_rand not working correctly?
- WP_Query() load selected post
- How to get post category list as select in front-end?
- Order a WP_Query by meta value where the value is an array
- How to extract information from a wp_query result?
- posts_nav_link pulling in multiple post types
- Modifying WP URL handing code?
- orderby meta_value_num is not working, giving default order
- How can I modify this code to make the search box include tags and meta
- Free search and custom taxonomy query not providing the same result
- How do I reset $wp_query in a function?
- WP_Query for woocommerce products with a pattern as a post_title
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Replace a single variable with add_filter
- Nested Queries of decreasing specificity
- Wrong pagination results, page counter resets when navigating
- Sending simple variable on single page to WP JSON
- How to exclude meta no index pages from wp_list_pages
- meta_query search names when they have middle initials
- WP query posts BUT show the most recent and one per author
- Ajax filter with loadmore button
- Query by pagename not Working
- Display featured image of post type category
- Delete post meta by serialized meta value
- get_filtered_term_product_counts – Get product terms if any products
- Getting info about selected posts using one WP_Query
- 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
- Query doesn’t display text data with apostrophes
- How to return count of items found in SQL query
- Querying posts from wordpress with 2 or more conditionals
- SQL Query Search page
- For each 3 posts, show a different post type
- Can’t get data from audio media
- Display Year and Month from custom field + Age Calculator
- insert thumbnail image from php script
- Masonry layout within the loop
- Weird Behaviour: Not all WordPress Posts appearing
- Query category-specific, paginated posts and allow viewer to change sort order
- wordpress is_main_query() breaks
- allow previews outside wordpress folder (Outsourcing WP previews)
- Advanced Taxonomy query, with 3 post types
- Why does a meta_query break this WP_Query?
- 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?
- Three different queries on same page
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404
- How to show correct td of table tags in wp_query loop
- External WP_Query call from PHP crashed after version update
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?
- WordPress query_posts with multiple tax_query
- Filtering with Attributes – how to display all non-queried products below query
- WordPress Query with meta_key and order by another meta_key