Ok, so I’m doing a new project and we’re going to be using WordPress as a magazine CMS. In some cases we’ll have a cluster of articles about a topic and it will be natural to link from one article to another. So, here we are in final edit in WP.
We want to add a link from one draft article to another draft article in the cluster, but the target article hasn’t been published, so WP doesn’t show it in the Link to Existing Content
box. Sure, I can get the shortlink for the draft of the article I want to link to, but then I need to open that tab, get the shortlink (or the draft’s slug), move back to the post that I want to link from, add the link. Doing this occasionally is fine but as a constant task it’s crappy workflow.
Now, we can simply publish and then hurriedly go through the articles and link things, but that’s suboptimal. I can’t imagine all of the magazines and other sites that do periodical publishing with WP do that though. I’ll play with Editflow to see if it has a way to deal with this, but does anyone know of a way to link from one draft to another and have the link be correct when they’re both published?
And yes, I know I can link things up after publishing. See ‘crappy workflow’.
This is very similar to this question.
We have to hook into
check_ajax_referer
to address the internal linking feature only. Then we register an action forpre_get_posts
to extend the search to drafts and pending posts.We will still get no pretty permalinks, because they are excluded in
get_permalink
. So we register a filter for that too and ask WordPress again for a permalink, but with a faked post status.As code: