WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#113 closed defect (bug) (fixed)

Post content 'lost' if multiple <!--more--> (more...) tags used.

Reported by: tormodh Owned by: ryan
Milestone: Priority: normal
Severity: minor Version:
Component: Template Keywords:
Focuses: 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 (1)

0000113-multiple-mores.diff (556 bytes) - added by tormodh 10 years ago.

Download all attachments as: .zip

Change History (8)

comment:2 @tormodh11 years ago

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.

comment:3 @mark11 years ago

<!--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-->.

comment:4 @tormodh11 years ago

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 @coffee2code11 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>.

comment:6 @ryan11 years ago

  • Owner changed from anonymous to rboren
  • Resolution changed from 10 to 20
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.