I have to define non-paywall and paywall text in the_content()
; per google rules, so far I tried:
$content = apply_filters('the_content', get_the_content());
$str = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
$str = strip_tags($str, '<a><strong><em>');
$first_slice = $str;
$second_slice = substr($content,strlen($first_slice),strlen($content));
echo '<div class="non-paywall">'. html_entity_decode ( $first_slice ) .'</div>';
echo '<div class="paywall">'. html_entity_decode ( $second_slice ) .'</div>';
This shows first paragraph well, and ends word without trimming its characters, and then it repeats one word in second slice and continues text. This is what I tried, but not actually what I need.
I need this structure:
<div class="non-paywall">
Paragraph 1
Paragraph 2
</div>
<div class="paywall">
Paragraph 3
...
To the end.
</div>