Skip to content

Instantly share code, notes, and snippets.

@ryozi-tn
Created February 21, 2016 16:04
Show Gist options
  • Save ryozi-tn/176be5accaed02c34abe to your computer and use it in GitHub Desktop.
Save ryozi-tn/176be5accaed02c34abe to your computer and use it in GitHub Desktop.
// simply fixed custom permalink
// dependencies: Custom Permalinks (plugin)
class Test{
public function __construct()
{
add_filter('get_sample_permalink_html', array(
$this,'get_sample_permalink_html'
), 999, 4);
}
// fixed permalink: 'original-post'
public function get_sample_permalink_html($html, $id, $new_title, $new_slug)
{
// replace target: '?post_type=any&p=67'
// to: 'original-post'
$search_value = htmlspecialchars(sprintf('?post_type=%s&p=%d', 'original', $id));
$replace_value = "original-post";
$replaced_html = str_replace($search_value, $replace_value, $html);
return $replaced_html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment