The crux is that the tip depends on the HTML rendering order (the “source ordering”). It relies on themes adhering to the content-first principle. That is: It relies on content being rendered first, so that the TOC plugin has a chance to collect headings. When sidebars are rendered first, the TOC plugin has not seen any headings yet, and nothing is rendered.
Nowadays most themes are good citizens in that they adhere to the content-first principle, a lucky situation much of which is owed to SEO considereations. But there are exceptions, like the Oriental theme.
Here’s what you can do about it:
- Open the file single.php. Near the top you’ll find a statement like this:
<?php get_sidebar(); ?>
- Copy the statement to the clipboard.
- Comment it out like this:
<?php //get_sidebar(); ?>. Or simply delete it.
- Scroll down to the bottom of the file. There you should find a statement like this:
<?php get_footer(); ?>
- Just before it, paste the previously copied statement from the clipboard.
- Repeat the procedure with the file page.php.
Note that this fix probably won’t work with every theme. Only themes which base their layout on CSS, not source ordering, can be fixed like this. But that should be the case with most themes today.
That’s it for today.
Cheers and happy blogging.
- How To Auto-Collapse TOC Boxes
- How To Couple a TOC Box to an Image
- Table Of Contents In The Sidebar
- Placing a TOC In The Sidebar Revisited - First Aid For Naughty Themes