I am using a plugin called Automatically Paginate Posts to parse our posts and to split them into multiple pages by automatically inserting the nextpage tag after a certain number of words. It always rounds up though to the next whole paragraph so that paragraphs do not get cut in the middle. A lot of the paragraphs in the posts have h2 subtitles above them though, but they are often getting parsed separately from the paragraph that they go with (this is an example: http://www.pantryspa.com/home-and-garden-remedies/bedroom-remedies/konmari-method-for-organization-declutter-your-life-with-the-joy-test/) ... that last h2 subtitle "GMA: KonMari Method for Organization" should really be on the next page above the paragraph it is about. So I'm trying to figure out how to get the h2 subtitles to be considered "part" of the following paragraph. I figured this was easiest by replacing
<h2> tags with
<p><h2> and by replacing
</h2><p> with just
</h2>, but something isn't working about that (perhaps because of the new line or space between the
</h2> and the
<p> on the next line)?
This is the php that I wrote and edited the plugin's php to contain:
$content = preg_replace( '#</h2>\r\n<p>#', "</h2>", $content ); $content = preg_replace( '#<h2>#', "<p><h2>", $content );
but that doesn't seem to work.
I have granted support access via the wpmu plugin, in case that helps.
Thanks for your help!
Here is the code that I added to the plugin:
$content = preg_replace( '#</h2>\r\n<p>#', "</h2>", $content );
$content = preg_replace( '#<h2>#', "<p><h2>", $content );