WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to insert links in Wordpress's wysiwyg editor that will convert to pretty permalinks when enabled?

i.e. the links would be this without pretty permalinks:


But with permalinks on, it would become this:


I'm thinking I'd have to use a shortcode to do that right? Something that would use the ID and wp_list_pages() for pages at least... just thinking about a way to get links in content to work when permalinks are on and off.



share|improve this question
up vote 2 down vote accepted

Here is example of simple shortcode that will take ID as argument and echo permalink for it:

function link_from_id($atts) {

    if( isset($atts['id']) )
        return get_permalink( (int)$atts['id'] );

add_shortcode('link', 'link_from_id');


[link id=1]

PS by the way non-pretty permalinks will keep working just fine if you enable pretty mode later and, if I remember right, will be redirected to canonical pretty version.

share|improve this answer
Thanks for this Rarst, much appreciated - and you're right about non-pretty permalinks working in both contexts. – Osu Jan 27 '11 at 19:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.