Mairaj Future Links

Description

When you plan a series of posts, the first one often wants to link to the next one, which is still scheduled. Without this plugin you either leave the link out and come back later to add it, or you publish a link that leads readers to a 404.

Mairaj Future Links lets you add the link now. While the target post is scheduled, a draft, pending review or private, the link is shown as its plain text. When the target post is published, the link appears by itself. You never have to go back and edit the older post.

  • Works with any permalink structure, pages, custom post types and ?p=123 links, because it uses WordPress’s own URL lookup.
  • Only touches links to your own site. External links, anchors and relative links are left alone.
  • Does nothing to the stored post content: the link stays in the editor, and only the page readers see changes.
  • No settings, no database tables, no scripts or styles added to your pages.
  • When a post goes live, the plugin clears the object cache of published posts that link to it.

The replaced text is wrapped in <span class="mairaj-future-link">, so you can style it if you want.

For developers

  • mairaj_future_links_statuses filters which statuses count as “not live yet” (default: future, draft, pending, private).
  • mairaj_future_links_replacement filters the HTML that replaces a link. It receives the link text and the original URL.
  • mairaj_future_links_skip returns true to leave links untouched for the current request.
  • mairaj_future_links_linking_post fires for each published post that links to a post that just went live. A page-cache plugin can purge that page here.

Installation

  1. Install the plugin from the Plugins screen, or upload the mairaj-future-links folder to /wp-content/plugins/.
  2. Activate it. There is nothing to configure.
  3. In any post, link to a scheduled post by its URL as usual.

FAQ

How do I get the URL of a scheduled post?

Copy the permalink shown in the editor’s sidebar for the scheduled post. Links in the form https://example.com/?p=123 also work.

My page cache still shows the plain text after the target went live.

Mairaj Future Links clears WordPress’s object cache for the linking posts, but full-page caches are separate. Purge the cache, or let it expire. Cache plugins can hook into mairaj_future_links_linking_post to purge the right pages by themselves.

Does it change my posts in the database?

No. It only changes the HTML when a post is shown. Deactivate the plugin and every link shows again as you wrote it.

Is a link to a draft post hidden too?

Yes, if the draft already has a permalink (WordPress gives drafts one once you set or edit their slug). Use the mairaj_future_links_statuses filter to change which statuses count.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Mairaj Future Links” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Mairaj Future Links” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.0.0

  • First release.