Per Søderlind

I code for fun

WordPress plugins and permalinks, how to use pretty links in your plugin

I’m working on a plugin, Read Offline, and one of the wishes was for url friendly links. After intensive googling, here’s how I did it:

“My Permalink Demo” plugin:

How to test the “My Permalink Demo” plugin

  • Save the code above as wp-content/plugins/ps_my_permalink.php, or get the plugin from
  • Activate the “My Permalink Demo” plugin
  • add the [mypermalink] or [mypermalink val="ipsum"] shortcode to a page or post


  • Debugging permalink errors is hard, I highly recommend Rewrite Analyzer (it helped me).



  • Thanks to Paul, the plugin now only flushes the rewrite rules when needed.


  • Fixed a bug in my_permalink_url() that gave 404 for blogs in a subdirectory


  • Initial release


Making cbnet Multi Author Comment Notification 1.1.2 WordPress multisite aware


WordPress and Pow


  1. Thanks. I’ve been meaning to look into how this works for a while now.

  2. Hei Per, Really helpful plugin. I was looking into this and felt my brain getting fried, I am really happy I stumbled onto your plugin. :-)

    I have a guestion though, maybe it´s a stupid one, but I hope you can help me. In your code for the function my_permalink_parse_request, where I can add what I want to preview. I want to preview a page witch have another shortcode tag in it witch is specified in my code. So that it previews the hole wordpress page etc.. I can´t seem to understand how to do this by the way you have coded this? Can you shed some light please?

  3. Just a little additional comment. As an example for the plugin, it would be nice to know how you would use my_permalink_parse_request to call so that it will print out the result back to the page that you have your [mypermalink] on to or another page, but the most important is that it will actually print all the template of the theme that you are currently installed. Does that make sense? Please let me know if you want me to clarify. :-)

Leave a Reply

Powered by WordPress & Theme by Anders Norén