Fix: WordPress Post Content Disappears with Too Many Shortcodes
I’ve been working on a longer post that I plan on splitting up over several pages. It’s a tutorial/walkthrough that includes a lot of images. Everything was going great until I decided to preview the post. For some reason when I viewed the post, it would only show the post title and metadata, but not the actual content of the post.

I closed the preview and went back to the post’s edit page to see if I could find any issues. I didn’t see anything wrong with the HTML or the shortcodes, so I decided to start deleting sections of the post to try and narrow down the issue.
After a lot of trial-and-error, I discovered that the content would show up if I left all of the content up to the first 11 images and about 100 characters after the 11th image. If I added one more character, the post content wouldn’t show up when I previewed the post.
After a few minutes of google-fu I came across a potential solution. Apparently posts with a lot of shortcodes (such as the shortcode used for images) can suffer from this issue. I wasn’t able to determine the exact combinations of shortcodes and words a post can have before it “breaks,” but I found this post on the WordPress.org support section that suggested editing the wp-config.php
file on my web server and increasing the memory and backtrack limit. I also found this post that suggested increasing the recursion limit as well. I added the following lines of code to the top of my wp-config.php
file:
define('WP_MEMORY_LIMIT', '64M');
ini_set('pcre.recursion_limit', 20000000);
ini_set('pcre.backtrack_limit', 1000000);
The first several lines of my wp-config.php
file now look like this:
<?php
define('WP_MEMORY_LIMIT', '64M');
ini_set('pcre.recursion_limit', 20000000);
ini_set('pcre.backtrack_limit', 1000000)
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information by
* visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
This did the trick, and I didn’t even have to restart my Apache server to get it to work! I’m sure this isn’t a cure-all for everyone who encounters this issue, but hopefully it will be helpful to someone.
Comments
Comments are closed