TOC Malfunction Rumors Disproved Again

Jul 17, 2009   //   by Hackadelic   //   WordPress  //  No Comments
This entry is part of a series, TOC Misconceptions»

Marvin from The Hitchhiker´s Guide to the Galaxy - not againIn my last post I disproved that SEO Table Of Contents fails to function on a very long post/page with more than 12,500 characters. As it turned out, it wasn’t characters that the issuer meant, but words. So I re-checked with a much longer post.

I discovered two things:

  1. It is true that the post/page content disappears when the content size increases above a certain limit. (The limit seems to be different on different servers).
  2. It is not true that this is caused by the TOC shortcode. The content disappears with any shortcode inside the content.

Here is the source code of a simple plugin I used to investigate the issue:

<?php
/*
Plugin Name: Hackadelic ShortCodeDummy
Version: 0.1
Plugin URI:
Description: A simple dummy shortcode to test WordPress' shortcode processing.
Author: Hackadelic
Author URI: http://hackadelic.com
*/

add_shortcode('SHORTCODE', 'HackadelicShortCodeDummy');

function HackadelicShortCodeDummy($atts, $content=null){
	return "{SHORTCODE was here}";
}

?>

It adds the shortcode [SHORTCODE], which just yields “[SHORTCODE]”. It attempts no content processing whatsoever. Nonetheless, in a huge post it will make the content disappear, like any other shortcode will. (Note though that you can’t just use [XXX] of the like. The shortcode needs to actually have been registered with wordpress.)

This is not the plugin, but WordPress’ shortcode processing which fails. I examined the issue in the past (in conjunction with similar rumors about Sliding Notes), and came to the conclusion that it is most likely a bug in PHP’s regular expression engine.1

Sorry, nothing I can do about that. 🙁

Interestingly though, a TOC in the sidebar works flawlessly with huge posts.  So that’s a possible workaround – if you must write your next novel in WordPress. 🙂

  1. This explains why on different servers – with different PHP versions and configurations – there are different limits on the post length. []
Entries in this series:
  1. TOC Malfunction Rumors Disproved
  2. TOC Malfunction Rumors Disproved Again
Powered by Hackadelic Sliding Notes 1.6.5

Comments are closed.

Blog Categories

I have come here to chew bubblegum and kick ass...
and I'm all out of bubblegum.
-- Nada in They Live