Ticket #113 (closed defect (bug): fixed)

Opened 8 years ago

Last modified 7 years ago

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

Reported by: tormodh Owned by: ryan
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

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

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.

comment:3   mark8 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-->.

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.

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   ryan8 years ago

  • Owner changed from anonymous to rboren
  • Status changed from new to closed
  • Resolution changed from 10 to 20

comment:7   matt7 years ago

tormodh7 years ago

Note: See TracTickets for help on using tickets.