Ticket #113 (closed defect (bug): fixed)
Post content 'lost' if multiple <!--more--> (more...) tags used.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | |
| Severity: | minor | Keywords: | |
| Cc: |
Description
In file /wp-includes/template-functions-post.php line 117:
$content = explode('<!--more-->', $content);
explode() splits $content into number of '<!--more-->' + 1 parts. Only $content[0] and $content[1] is used. If, for any reason, more '<!--more--> tags get in the post, content after the secont is not displayed.
Attachments
Change History
Fix should be:
$allcontent = ""; for ($counter = 1; $counter < count($content); $counter++) {
$allcontent .= $content[$counter];
} if ($more) {
$output .= '<a id="more-'.$id.'"></a>'.$allcontent;
Three errors. Counting beyond array with <= Adding to wrong variable $count Only using last content ($allcontent = $content[$counter];)
Sorry. Tired.
<!--more--> is suppose to be used only once (as far as I know and makes sense to me). For more pages, you should use <!--nextpage-->.
Yes, I agree with that. My thought was in the direction of userfriendly-ness. In case any user by any reason, or without reason, adds an extra <!--more--> somewhere - any content after the second <!--more--> won't show.
Um. My reasoning is that if <!--more--> is not to be used more than once, $content shouldn't be split into more than two parts, or all subsequent parts of $content needs to be set back together.
comment:5
coffee2code — 8 years ago
Simple fix for this:
in wp-includes/template-functions-post.php, function get_the_content().
Change this:
$content = explode('<!--more-->', $content);
to:
$content = explode('<!--more-->', $content, 2);
I've attached a diff. Also discussed the change <a href=" http://www.coffee2code.com/archives/2004/08/03/patch-dealing-with-multiple-more/">here</a>.
- Owner changed from anonymous to rboren
- Status changed from new to closed
- Resolution changed from 10 to 20

