Custom Post Permalink Filter

There are some situations where you might wish to have a post permalink point to a different URL than the default.

This is especially applicable for blog-style “asides” or newsy quick-hits like you might find on the Drudge Report, Daring Fireball, or Kottke.

You can use the WordPress post_link filter to return a custom post permalink.

Note: These instructions assume you are using a PHP customization class to organize your custom code.

public function front_end() {
	/* Hooks and filters that affect the front end _only_ go here */
	add_filter('post_link', array($this, 'custom_post_link'), 10, 3);

public function custom_post_link($url, $post, $leave) {
	/* Access the $post object if you want, and then return a new URL */
	return [some new URL];