Title: inserting wp post title into php code
Last modified: August 25, 2020

---

# inserting wp post title into php code

 *  [bizzyfizzy](https://wordpress.org/support/users/bizzyfizzy/)
 * (@bizzyfizzy)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/)
 * Hi, i’m trying to insert wp post title into the following php code:
 *     ```
       // What to look for
       $search = 'insert the wordpress post title here';
       // Read from file
       $lines = file('links.txt');
       foreach($lines as $line)
       {
         // Check if the line contains the string we're looking for, and print if it does
         if(strpos($line, $search) !== false)
           echo $line;
       }
       ```
   
 * and this code searches are case sensitive, how can i make it non-case sensitive?
   
   Thanks in advance.
    -  This topic was modified 5 years, 9 months ago by [bizzyfizzy](https://wordpress.org/support/users/bizzyfizzy/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/#post-13312158)
 * [https://developer.wordpress.org/reference/functions/get_the_title/](https://developer.wordpress.org/reference/functions/get_the_title/)
   and [https://www.php.net/manual/en/function.stripos.php](https://www.php.net/manual/en/function.stripos.php)
    -  This reply was modified 5 years, 9 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
    -  This reply was modified 5 years, 9 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [bizzyfizzy](https://wordpress.org/support/users/bizzyfizzy/)
 * (@bizzyfizzy)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/#post-13312232)
 * Hi, thank you for your reply Steven. I’ve already tried to put `<?php the_title();?
   >` here: `$search = '<?php the_title(); ?>';` but it doesn’t work. I’m a newbee
   so could you show me where to put that code please? Thank you.
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/#post-13312402)
 * “the_title()” echoes the post title. You need “get_the_title()” as that returns
   a string.
    -  This reply was modified 5 years, 9 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/#post-13312436)
 *     ```
       // What to look for
       $search = get_the_title();  // you may need to add parameters to the functionall.
       // Read from file
       $lines = file('links.txt');
       foreach($lines as $line)
       {
         // Check if the line contains the string we're looking for, and print if it does
         if(stripos($line, $search) !== false)
           echo $line;
       }
       ```
   
 *  Thread Starter [bizzyfizzy](https://wordpress.org/support/users/bizzyfizzy/)
 * (@bizzyfizzy)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/#post-13312574)
 * Hi again Steven, thank you very much for your help. Have a nice day.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘inserting wp post title into php code’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [title](https://wordpress.org/support/topic-tag/title/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [bizzyfizzy](https://wordpress.org/support/users/bizzyfizzy/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/inserting-wp-post-title-into-php-code/#post-13312574)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
