Last week I got into a conversation with my friend Fletcher about linking to internal pages in WordPress. To wit, it could be a lot easier. Wiki-style links would be better than nothing, but personally I hate having to remember special codes for things. Still, WordPress’s shortcode API does make this relatively easy to accomplish, and sure enough, someone had already done more or less what I wanted. His shortcodes look like this:[[link pagename=”My Example Page”]]
That wasn’t quite right, though. I wanted to use slugs instead of proper names, and include IDs, and be able to link to things other than posts and pages. So I’ve taken it a little further:
(Later this week I’ll probably add custom taxonomy support, now that I’ve sussed out how that works.)
So, mission accomplished… sort of. Fletcher would like something shorter, but we’re constrained by the API. We can’t have [[link 2130]], which would have been my first choice.
How could this be better? I’m thinking of adding a button to the visual editor toolbar that would pop up and prompt you for the ID or slug. If I can figure out how to put an auto-suggesting search box in that popup, I will. The HTML editor is trickier… I know I could put a button in for each of the various formats, but that’s a lot of buttons. I’m not sure if the quicktag popups support more than one input field. Suggestions welcome!