In a WordPress theme, I need to separate a gallery from the rest of the_content.
I think one could do that with get_the_content and preg_replace but it’s a little beyond my skill level how to actually implement the solution.
Here are the specifics. There’s a gallery that looks like this:
<div class="gallery">
<section class="clearfix">
<div class="gallery-row">
some <figures>
</div>
</section>
</div>
the rest of the content
Is there some way I could get that gallery into a variable and put all the rest of the content in another variable.
Then I could just echo the variables wherever I wanted, right?
The easiest way to do that is to hijack the gallery shortcode (no extra regex needed), store it somewhere and add it to the end.
Prototype