Once an article reaches a certain length, it is valuable to allow linking to a specific part of the page by creating anchor locations. Unfortunately, creating an anchor location in WordPress involves writing raw HTML, which is not an ideal client solution. There are other solutions out there but Blinebury Design wanted a specific set of behavior for their clients, so we built the Anchor Shortcode Plugin for WordPress.
The basic idea is clients can create a target anchor location by using a shortcode. This means instead of writing
can be used. This shortcode can be used multiple times with different values for the
id, allowing you to setup different target locations.
While the shortcode itself is not a great gain, we also added an Anchor button to the WordPress TinyMCE editor.
This button prompts the user for an ID value, which is then formatted properly, and displayed in the editor as a shortcode.
This was an interesting project because while the shortcode itself is pretty straight forward, integrating in the TinyMCE WYSIWYG toolbar was a different challenge.
Blinebury Design was also generous enough to open source this plugin, which is available on GitHub as the Anchor Shortcode plugin for WordPress.
If you find this code useful, you might want to send them a tweet of thanks.
Leave a Reply