Title: WordPress function to remove prepositions
Last modified: February 18, 2021

---

# WordPress function to remove prepositions

 *  [leonleles](https://wordpress.org/support/users/leonleles/)
 * (@leonleles)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/wordpress-function-to-remove-prepositions/)
 * I want to remove prepositions from strings. Example prepositions:
 * – in;
    – at; – to; – from; – the;

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

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/wordpress-function-to-remove-prepositions/#post-14069421)
 * You can write regex expressions that could do this.
    Then you could use filters.
   Suggest that you look into the PHP regex functions.
 *  [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * (@corrinarusso)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/wordpress-function-to-remove-prepositions/#post-14070587)
 * Regex is good.
    It depends on what the data looks like at your source, and what
   tool you plan to use for the action.
 * In PHP you could use str_replace()
    [https://www.php.net/manual/en/function.str-replace.php](https://www.php.net/manual/en/function.str-replace.php)
 * If I’m assuming correctly, you are looking at your URLs?
    You could download 
   your post id, and URL, and put all the URLs in an array. Loop through each element
   and kick off a str_replace() that finds in your string, and replaces it with 
   nothing. There is also preg_replace : [https://www.php.net/manual/en/function.preg-replace.php](https://www.php.net/manual/en/function.preg-replace.php)

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

The topic ‘WordPress function to remove prepositions’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [corrinarusso](https://wordpress.org/support/users/corrinarusso/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/wordpress-function-to-remove-prepositions/#post-14070587)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
