Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Very long post shows up empty on front end WordPress

I have a very long post—15,900 words (1,000 lines, about 113 kb when I save it as a text file).

It shows up fine in the edit screen, but on the front of my site, it shows up empty. There are no errors and everything else on the page shows up fine, but there is no text where the_content() should be.

Here are my findings during the course of troubleshooting:

• If I shorten the post by about 20%—just removing text, not removing any of the shortcodes— the post works fine.
• The post uses about 15 instances of a custom shortcode. If I comment out that shortcode's function from my functions.php file, the post works fine. (The shortcode works fine in all other posts.)
• The post [[LINK href="http://www.undermyhat.org/blog/2009/07/sudden-empty-blank-page-for-large-posts-with-wordpress/"]]here[[/LINK]] ("Sudden empty / blank page for large posts with WordPress") suggests that this is a shortcode parsing issue that can be solved by increasing the PCRE recursion limit to 200x normal in PHP settings. I did this and it had no effect.)

My PHP settings are here: http://bit.ly/tRbi6o
The shortcode function is here: http://bit.ly/uunhKX

Any idea how I can solve this problem?

Answers (7)

2011-11-15

Hai Bui answers:

Hi,

I think this problem may be due to lack of memory for PHP script, please try these solutions:
- Change memory_limit in PHP.ini If the current value is 16M, try 32M:
memory_limit = 32M ; Maximum amount of memory a script may consume (32MB)

- Add this line to your wp-config.php file to increase memory allocated to PHP:
define('WP_MEMORY_LIMIT', '32M');

If it does not work, try increasing the number to 64M.


web559 comments:

As noted in the copy of my PHP settings, PHP memory is already at 64M. Unfortunately the WP_MEMORY_LIMIT constant didn't have any effect.

2011-11-15

Romel Apuya answers:

you might need to edit your wp-admin php.ini
try this link

[[LINK href="http://wptheming.com/2009/07/upload_max_filesize/"]]http://wptheming.com/2009/07/upload_max_filesize/[[/LINK]]


Romel Apuya comments:

you might also try

get_the_content();

instead of the_content();

and see of it has a difference.

2011-11-15

Duncan O'Neill answers:

Hi,

can you please post the url for the post?

thanks,


web559 comments:

I can't share the URL, unfortunately.


Duncan O'Neill comments:

OK,

just to state the obvious, I guess you've tried enabling error reporting?


ini_set('display_errors', 1);
error_reporting(E_ALL);


and / or this is in your /wp-config.php


define('WP_DEBUG', true);


web559 comments:

Unfortunately, error reporting doesn't reveal anything that appears to be relevant to the missing content.

2011-11-15

Francisco Javier Carazo Gil answers:

Hi,

You can try this.

At the top of wp-config.php, add the following code:

ini_set("pcre.backtrack_limit", 10000000);

In php.ini, change also the same:

Remove this line:
pcre.backtrack_limit=100000


For this one:
pcre.backtrack_limit=1000000

If you don't solve the problem, I recommend you to use: <!--nextpage-->, see how it works in the [[LINK href="http://codex.wordpress.org/Styling_Page-Links"]]Codex[[/LINK]]. It's clear and maybe you prefer have pagination inside your post.

Hope it helps.


web559 comments:

As I noted, I tested the PCRE changes outlined in [[LINK href="http://www.undermyhat.org/blog/2009/07/sudden-empty-blank-page-for-large-posts-with-wordpress/"]]this post[[/LINK]], without success. Adding the ini settings to wp-config.php didn't make a difference, unfortunately.


Francisco Javier Carazo Gil comments:

Have you tried <!--nextpage-->?


web559 comments:

I am sure it would work, but it's not what I'm looking for.

2011-11-15

Sébastien | French WordpressDesigner answers:

i use your code (shortcode) on mys test-site.
send me your content (long and complete)
i want to know if the problem exist on my site
if it exist, the problem could go from your code

2011-11-15

Luis Abarca answers:

I think you can try to rise the memory limit + time limit + split the post in 2 pages with "Next button"

raise the memory limit in your php.ini or htaccess

memory_limit = 64M


Raise the php time limir to process your post

// you can check for the slug or ID too, to just raise the time to a particular post
if ( is_single() ) :
set_time_limit( 90 );
endif;

2011-11-16

Gabriel Reguly answers:

Hi web559,

Do you still have the issue?

May I suggest a 'low-tech' approach?

Why don't you get the first half of the content (using ob_get_contents), get the second half, merge them and finally show the full content?

Regards,
Gabriel


web559 comments:

How could ob_get_contents be used to get half of the content? I'd only want to go that route if there were a programmatic way to do it—something like a hook that checks if a post is really long, and if it is, splits it in two and returns the sum to the_content.


Gabriel Reguly comments:

Hi web559,

Is it worth to code a hook because of only one post? Or do you expect to have more posts like this one?

Anyway, first you need to find out what is a long post:

Is it long because of number of characters?
Is it long because number of [shortcodes]?
Or will you be checking if the_content() is empty?

Then you will need to 'split' the post using the same technique WordPress uses for <!--nextpage--> combined with the ob_get_contents() approach.

Does it make sense to you?

Regards,
Gabriel


Gabriel Reguly comments:

Hi web559,

Have got the time to read my last post?

Regards,
Gabriel