See that sweet Magellan menu over on the right sidebar (if you’re not viewing the AMP version of this page)? →

Pretty cool right?

  • It acts as a nice table of contents for the post (and it’s 100% automatic!).
  • You can click the links to smooth scroll down to that section.
  • As you scroll, the visible section is highlighted.
  • It’s also inside of an awesome Theia Sticky Sidebar.

I’ll show you how to implement it into your own WordPress site.

What is a Magellan Menu?

Magellan is a fixed position menu that scrolls to the related anchor on click and follows you as you scroll, highlighting the active menu item.  It is a component that comes with the Foundation front-end framework (one of the most popular front-end website frameworks, competing with Bootstrap).

The same functionality could easily be translated to use ScrollSpy for Bootstrap.

How to Implement the Magellan Menu Functions and Shortcode

You should be able to drop the below code into your theme’s functions.php file.  It has all of the functions used to…

  • Get the text of all your post’s h2 tags.
  • Create a slug out of those h2 tags’ content.
  • Generate the Magellan menu.
  • Manipulate the post content to insert Magellan target slugs into the h2 tags.
  • Set up a simple little shortcode so you can put the Magellan menu wherever you want.

How to Place the Magellan Shortcode

Once you have the above code in place, placing the Magellan menu is as simple as typing the magellan shortcode in a sidebar widget.  Like this…

How to Make the Magellan Menu Sticky

There are lots of ways to make the Magellan Menu (or the widget area) sticky, but since the content of this menu is dynamic and could potentially be very long and not fit on the screen, I suggest using the Theia Sticky Sidebar.

How to Add a Scrolling Sticky Sidebar to WordPress

Comments or Question?

Let me know what you think.  Also, if you’re having issues getting yours to work properly, let me know where you’re stuck.  I’m happy to help.

Leave a Reply

avatar
  Subscribe  
Notify of