Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:20:29+00:00 2026-05-24T07:20:29+00:00

OK WordPress PHP gods, here is a good one. I want to compare the

  • 0

OK WordPress PHP gods, here is a good one. I want to compare the TAGS against the Post Content, if the TAG appears in the Post Content, then I want it to output. If it doesn’t appear in the content, then don’t.

  1. I am presuming that I would need to output the TAGS as an Array

  2. If I do the same for the Content, using (correct if incorrect) ‘Explode’ then each word would be single. Consider ‘The Lazy Brown Fox’, if I had a TAG ‘Brown Fox’

So in short I am stumpped, and have no idea how to proceed. I am VERY sure that this post would interest many people.

Many thanks for your advice in advance

Stu

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:20:31+00:00Added an answer on May 24, 2026 at 7:20 am

    Rather than exploding the words in the post, why not use strpos()? This would take care of the multiple word tags.

    $tags = get_the_tags($post->ID);
    $stripped = strtolower(strip_tags($post->post_content));
    $tags_to_output = array();
    foreach($tags as $tag){
        if (strpos($stripped, strtolower($tag->name)) !== false){
            $tags_to_output[] = $tag;
        }
    }
    

    If you were really worried about it you could replace multiple whitespace characters in $stripped

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
Quick question about Wordpress PHP: I am writing a theme and I want to
I have created a searchfrom.php for wordpress but then it's giving me a false
There seems to be a bug in a Wordpress PHP function that leaves whitespace
I am a newbie to both PHP and Wordpress (but do ok in C#),
I just saw this code while studying the wordpress source code (PHP), You can
I am creating a small utility which will help to rebuild install.php of WordPress.
WordPress allows theme designers to place a 404.php file in their theme's directory. This
in wordpress , i set a variable in header.php <?php $var= 'anything' ?> but
I wrote a small PHP application several months ago that uses the WordPress XMLRPC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.