Curently if we use the insert link dialog to insert a link to another post, WordPress always use the permalink of that post. The problem is when we change permalink structure, that link will be broken.
I’d like to ask if there is a way to change the link from permalink to shortlink like ?p=123
to make it work in any circumstance.
Thanks.
The links in that dialog are made by
wp_ajax_wp_link_ajax()
(seewp-admin/includes/ajax-actions.php
, there is no page on Codex or queryposts.com for that function).To change the links filter
'page_link'
,'post_type_link'
,'post_link'
and maybe'attachment_link'
aftercheck_ajax_referer()
was called for the action'internal-linking'
.Okay, sounds a little bit complicated, but it is really easy. 🙂
Plugin on GitHub: https://gist.github.com/3731739
But … when you change permalinks you have to create redirects in a server configuration file anyway to redirect existing URLs. So I am not sure if this plugin is really needed.