Previously, to add an ad code after the account identified </h2> used the following code
add_filter('the_content', 'wpse_ad_content'); function wpse_ad_content($content) { if (!is_single()) return $content; $paragraphAfter = 2; //Enter number of paragraphs to display ad after. $content = explode("</h2>", $content); $new_content = ''; for ($i = 0; $i < count($content); $i++) { if ($i == $paragraphAfter) { $new_content.= '<div style="margin-bottom: 10px;">'; $new_content.= 'Рекламный блок'; $new_content.= '</div>'; } $new_content.= $content[$i] . "</h2>"; } return $new_content; }
Now you need to add the code after the closing </div> certain class. Each entry has a block to share from Yandex, it is wrapped in <div class="ya-share2"> after this closing </div> and you want to add the code.