Title: Getting wp-title as a php string variable
Last modified: August 18, 2016

---

# Getting wp-title as a php string variable

 *  [bmaples](https://wordpress.org/support/users/bmaples/)
 * (@bmaples)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/getting-wp-title-as-a-php-string-variable/)
 * I’m trying to mess around with .php to do some customization, but I can’t figure
   out how to pull the post title into a .php string so that I can manipulate it.
 * I can make is display with <?php wp_title….
 * But how can I get the post title into a .php string?

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

 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/getting-wp-title-as-a-php-string-variable/#post-313176)
 * `<?php
    $title=('This is the title'); ?>
 * `<title><? print($title); ?></title>`
 * Should work ?
    Of course the next step – getting the title into each page – is
   very different as everything uses the same header.php where this is all set. 
   On a page basis, it’s possible but a per-post basis could be long and complex.
 *  Thread Starter [bmaples](https://wordpress.org/support/users/bmaples/)
 * (@bmaples)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/getting-wp-title-as-a-php-string-variable/#post-313208)
 * Thanks.
 * But I’m mot trying to change the <title> tag.
 * I’m trying to get the wp-title into a string.
 * Like
    $str=wp_title if $str … etc.
 * But I can’t figure out how to get the wp_title into a string.
 *  [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/getting-wp-title-as-a-php-string-variable/#post-313210)
 * try $title = wp_title(‘»’, false);
 *  Thread Starter [bmaples](https://wordpress.org/support/users/bmaples/)
 * (@bmaples)
 * [20 years, 4 months ago](https://wordpress.org/support/topic/getting-wp-title-as-a-php-string-variable/#post-313213)
 * Thanks! That’s it.

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

The topic ‘Getting wp-title as a php string variable’ is closed to new replies.

 * 4 replies
 * 3 participants
 * Last reply from: [bmaples](https://wordpress.org/support/users/bmaples/)
 * Last activity: [20 years, 4 months ago](https://wordpress.org/support/topic/getting-wp-title-as-a-php-string-variable/#post-313213)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
