Adding page links to content that automatically convert to pretty permalinks?

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:

Read More

/?p=13

But with permalinks on, it would become this:

/mypagename/

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.

Thanks

osu

Related posts

Leave a Reply

1 comment

  1. 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');
    

    Usage:

    [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.