Title: Replace &#8211; with – in post title
Last modified: March 13, 2020

---

# Replace – with – in post title

 *  Resolved [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/)
 * Hi!
 * How to replace a short dash (-) with a long dash (–) in the post title?
 * I found only this (changed inside posts):
 *     ```
       add_filter( 'the_content', 'wpm_tire' );
       function wpm_tire( $content ) {
       	$content = str_replace( "--", "—", $content );
       	$content = str_replace( " - ", " – ", $content );
       	return $content;
       }
       ```
   

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

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12539290)
 * If it’s the post title you’d want to use the ‘the_title’ filter instead.
 *  Thread Starter [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12539338)
 * I don’t understand how the code should look like?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12539568)
 * It’s easy.
 * Change this line:
 * `add_filter( 'the_content', 'wpm_tire' );`
 * to this:
 * `add_filter( 'the_title', 'wpm_tire' );`
 *  Thread Starter [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12539816)
 * Thanks! But how to combine both?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12540821)
 * Do you know anything abut coding? If so, then it;s simple. If not, that’s OK,
   but I prefer to ask just in case.
 *  Thread Starter [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12541292)
 * No unfortunately I do not understand coding. I know HTML quite a bit.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12541327)
 * What I said is all that you need. Follow that and you will be fine.
 * If you cant’ follow that, then Id suggest that you try and pay someone else to
   do it for you.
 *  Thread Starter [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12541338)
 * Yes, your advice helped, but I need both settings. How to make them work together?
 *     ```
       add_filter( 'the_content', 'wpm_tire' );
       function wpm_tire( $content ) {
       	$content = str_replace( "--", "—", $content );
       	$content = str_replace( " - ", " – ", $content );
       	return $content;
       }
       ```
   
 *     ```
       add_filter( 'the_title', 'wpm_tire' );
       function wpm_tire( $content ) {
       	$content = str_replace( "--", "—", $content );
       	$content = str_replace( " - ", " – ", $content );
       	return $content;
       }
       ```
   
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12541349)
 * You need to read up on PHP more. You are close but… not quite there.
 * Just remember that a function can’t be declared more than once. And seeing as
   how you have two functions doing the same thing with the same name… you only 
   should have one.
 *  Thread Starter [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12550614)
 * I understand that you need to change something in the code, but I don’t know 
   what.
 * The code in the very first message I gave as an example.
 * I can’t understand how I can replace a short dash with a long dash in the titles
   and posts.
 *  [Jarret](https://wordpress.org/support/users/jarretc/)
 * (@jarretc)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12550660)
 * Hi, you need to use 2 different function names instead of using the same one.
   So your code should look something like the following
 *     ```
       add_filter( 'the_title', 'wpm_tire_title' );
       function wpm_tire_title( $content ) {
       	$content = str_replace( "--", "—", $content );
       	$content = str_replace( " - ", " – ", $content );
       	return $content;
       }
       add_filter( 'the_content', 'wpm_tire_content' );
       function wpm_tire_content( $content ) {
       	$content = str_replace( "--", "—", $content );
       	$content = str_replace( " - ", " – ", $content );
       	return $content;
       }
       ```
   
 *  Thread Starter [Asome](https://wordpress.org/support/users/asome/)
 * (@asome)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12550674)
 * Ohhhh yes! it is alive, alive! (с) scene from intro Weird Science (tv series).
 * **THANK you so much! You have helped me many times already =)**
 * It’s a pity that sometimes you can’t ask directly through private messages.

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

The topic ‘Replace – with – in post title’ is closed to new replies.

## Tags

 * [dash](https://wordpress.org/support/topic-tag/dash/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 3 participants
 * Last reply from: [Asome](https://wordpress.org/support/users/asome/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/replace-with-in-post-title/#post-12550674)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
