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!
Nojh says
Its a nice plugin. It’ll help me with my attempts to turn WordPress into a kind of wiki. I work for a company whose employees only meet through the net and we need a lot of net assets to continue to share work. A wiki’s markup language proved too difficult for some of the employees so the idea of using WordPress with minimal markup is definitely a step in the direction to satisfying those people.
The problem I see with my particular situation is that Steph’s solution is still markup. Which may yet still be off putting to some of my coworkers. The only solution I see is to include a GUI dialog on the entry editor which inserts these types of tags for you.
Of course as soon as you introduce GUI. You start asking for actual human usability. So why should I need to know the names of all of my pages, or their IDs? I should be able to search for the pages I want to link to. Another idea is multiple insertions.
Mind you I don’t do any development for WP so I’m not sure how feasible these ideas are. At the very minimum the button idea described would likely suffice, except that it should also prompt for a link name, if wanted, I should think. Is there a way to have the text inputted validated? IE when you submit, it checks to make sure there is a post or page of that name/id?
Shelley Keith says
Have you looked at RB Internal Links? I like the basic concept in the admin, though I think it could be simplified and cleaned up quite a bit. Essentially, for very novice users (like what I’m about to unleash on my poor install) the simpler the better.
I love your approach, but for my group I’d almost have to have a editor button that let them easily find the page/post they’re looking for. I’ll think through and see if I can come up with any actual solutions, rather than the very nebulous “make it easier”.
Stephanie says
I glanced at it and decided it wasn’t what I wanted. Does it have a lookup function I should
stealtake inspiration from?Stephanie says
Hmm. RB Internal Links did not work at all the first time I tested it — the pop-up window was blank — but I just tried it again, and you’re right, Shelley: this does almost everything I wanted. I like my syntax better, but… eh.
Shelley Keith says
I like your syntax better too. This is one of those situations where the existing tool works, but I really feel like it could be done with more finesse…more intuitively (if I can choose a seriously overused buzzword) for end-users.
Shelley Keith says
Ack, there was more. Thoughts on improvements:
1. The sliding popup from hell must die. If you have a large site it’s ridiculous to scroll through all of that looking for what you want to link to. I haven’t even begun to think about accessibility issues, but its lack of usability makes me crazy.
2. The popup is effected by things like universal header plugins in WPMU. I’ve had to do some serious css hacking to get my site-wide menu bar not to hide part of the RBIL menu monstrosity.
3. Since WP is going MU all the way in 3.0, it would make a LOT more sense for the plugin to offer ways to find things to link to in other “blogs” on the install. This would certainly make my life a lot easier
Nardo says
Can you share the exact code changes in the functions.php for this? I am not proficient in PHP and would particularly like to use the [link id=#”]link text[/link] feature…
steph says
The full code is here.
Cohen says
Hey Steph,
Author of the RB Internal Links plug in here. Totally agree with you RE sliding links, usability and accessibility. I have some time to update the plugin over the next few weeks and was wondering if you had any ideas on how to improve the interface?
If you do, drop me an email or post some bits on the forum, some input from other users would be helpful!
Cohen says
Opps, I meant Shelly, but either of your comments are most welcome! :)
Chris says
Nice one. I was trying to work out the best way to do that. Just realised I’ve been using full urls, which will screw me if I ever change to a different format!
Viet says
Hi Stephanie,
Thanks for sharing the idea about the link plugin. I was googling and found your site. It was almost 3 years since you posted and the plugin is gone (404). Could you please share it on WordPress plugin site? I noted that you have many great plugins there and many people find them useful.
Thanks,
Viet.
Stephanie Leary says
I’ve updated the link. Here you go! I’m not planning to release this as a plugin now that internal linking is supported in the WP editor.