Title: Check Hyperlinks on post save
Last modified: August 20, 2016

---

# Check Hyperlinks on post save

 *  [deroccha](https://wordpress.org/support/users/deroccha/)
 * (@deroccha)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/check-hyperlinks-on-post-save/)
 * How would be possible to get a clean coding workflow to change hyperlink structure
   on post save. So lets say an author has been created a post with hyperlinks `
   <a href="http://www.example.com"></a>`, on save I would like to control if meets
   the hyperlink given conditions to be redirected or not. If the url has to be 
   redirected than should change the structure of it `<a href="goto.html?url=http://
   www.example.com"></a>`. What I want to avoid is to not push the Author to give
   attention on link creation.

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

 *  [Spencer Cameron-Morin](https://wordpress.org/support/users/spencercameron/)
 * (@spencercameron)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/check-hyperlinks-on-post-save/#post-3024039)
 * I’m not sure I’m fully understanding, but here we go anyway. 😀
 * If your main goal is to filter post content and look for links that need to be
   changed ( if they meet a certain set of criteria ) without the author knowing
   about it, then try this:
 * **In your functions file:**
 *     ```
       function alter_links_in_posts( $the_content ) {
           // Do whatever you want to the content here:
   
           /*
            * Now anywhere you use the_content(), you'll get the
            * modified version you whipped up in this function.
            */
           return $the_content;
       }
   
       add_filter( 'the_content', 'alter_links_in_posts' );
       ```
   
 * [Shortcodes](http://codex.wordpress.org/Shortcode_API) may also be applicable
   depending on what exactly you’re trying to do.
 * Hopefully, this can get you started, at least. Just ask if any of this doesn’t
   make sense or I misunderstood you. 🙂
 *  Thread Starter [deroccha](https://wordpress.org/support/users/deroccha/)
 * (@deroccha)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/check-hyperlinks-on-post-save/#post-3024122)
 * Thanks a lot for your feedback in the main time I have been fixing this issue,
   and mainly as you suggested. Just one more thing what I would like to know. Is
   it possible to make this without to include the filter function in the template
   file. Is it possible to make a plugin for this? I’m new to wordpress
 *  [Spencer Cameron-Morin](https://wordpress.org/support/users/spencercameron/)
 * (@spencercameron)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/check-hyperlinks-on-post-save/#post-3024127)
 * It’s definitely possible to make this a plugin. In fact, it’s a great idea.
 * **Here’s what you could do:**
 *     ```
       <?php
       /*
         * Plugin Name: Filter Post Author Links
         * Plugin URI: http://codespanker.wordpress.com
         * Description: This plugin allow anchor tags in posts to be filtered/altered before output by the_content().
         * Author: Spencer Cameron - pippercameron@gmail.com
         * Version: 1.0
         * Author URI: http://codespanker.wordpress.com
       */
   
       function alter_links_in_posts( $the_content ) {
           // Do whatever you want to the content here:
   
           /*
            * Now anywhere you use the_content(), you'll get the
            * modified version you whipped up in this function.
            */
           return $the_content;
       }
   
       add_filter( 'the_content', 'alter_links_in_posts' );
       ?>
       ```
   
 * Copy-paste this code into a file and name it **whatever-you-want.php**. Make 
   sure you put this file in `wp-content/plugins/`. Once you do that, it will be
   available to activate from your plugins menu in WP admin. 😀

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

The topic ‘Check Hyperlinks on post save’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [Spencer Cameron-Morin](https://wordpress.org/support/users/spencercameron/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/check-hyperlinks-on-post-save/#post-3024127)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
