Make WordPress Core

Opened 20 years ago

Closed 20 years ago

Last modified 20 years ago

#113 closed defect (bug) (fixed)

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

Reported by: tormodh's profile tormodh Owned by: ryan's profile 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 19 years ago.

Download all attachments as: .zip

Change History (8)

#2 @tormodh
20 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.

#3 @mark
20 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-->.

#4 @tormodh
20 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.

#5 @coffee2code
20 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>.

#6 @ryan
20 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.