> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Linking Twitter usernames on WordPress posts automatically

> Automatically link Twitter usernames to their pages from WordPress content with a simple code snippet.

Learn how to use a short code snippet to autolink Twitter mentions on [WordPress](https://hosting.com/hosting/platforms/wordpress-hosting) posts to their respective pages. This article shows you how to add a short PHP code snippet to functions.php to autolink Twitter user names.

## Configuring autolink for Twitter usernames in WordPress articles

Follow the steps below to edit your Theme setting file:

1. Log in to your WordPress site with an administrator account.

2. On the **Dashboard** in the left sidebar, click **Appearance**, and then click **Theme Editor**: ![](https://static.hosting.com/kb/kb-wordpress-twitter-2.png)

<Warning>
  **Important**

  You will not be able to roll back to your earlier Theme configuration after any edits. Save the Theme files before proceeding with the modifications.
</Warning>

3. On the **Theme Editor**, select the **Theme** you want to edit from the dropdown:

***

4. Click on the file named "*functions.php*"

5. Copy and paste the following code block into functions.php.

```javascript theme={null}
function add_twitter_links($content) {
return preg_replace('/([^a-zA-Z0-9-_&amp;amp;])@([0-9a-zA-Z_]+)/', &quot;$1@$2&quot;, $content);
}
add_filter('the_content', 'add_twitter_links');
add_filter('comment_text', 'add_twitter_links');
```

6. Save the file and exit the editor.

## More information

For more information about the please visit the following link: [https://wordpress.org/plugins/theme-editor/](https://wordpress.org/plugins/theme-editor/)

## Related articles

* [Adding external RSS feeds to your WordPress site](/docs/adding-external-rss-feeds-to-your-wordpress-site)

* [Clearing the cache in WordPress](/docs/clearing-the-cache-in-wordpress)

* [Configuring WordPress date and time settings](/docs/configuring-wordpress-date-and-time-settings)
