Thanks for the reply, here the case
My blog is about design and useing attachment page, it means that 1 post contains at least 10 images which is linked to the attachment page.
In order to avoid little / thin content, then I take 1 random paragraph from the parent post (single post) to be displayed in attachement page.
I only use 2 ads because the theme actually has its own ads placement management, I use your great plugin to display Link Ad randomly in the single post only.
That’s the problem, sometimes the code is displayed in the attachment page (because I tried to take 1 random paragraph from the parent post)
here the screenshot of the full page of setting page, sorry for the heavy images _https://prnt.sc/c98fzi
and here the random.php that I use inside the attachment.php
<?php */random.php to display random paragraph */
$par = get_post($post->post_parent);
$content = strip_shortcodes($par->post_content);
$content = strip_tags($content, $tags);
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
/* stripping THAT content of tags that may have been added */
$content = strip_tags($content, '<p><a>');
/* and strip that of any inline styles */
$content = preg_replace('/(<[^>]+) style=".*?"/i', '$1', $content);
$content = str_replace('</p>','</p>[(.Y.)]',$content);
$content = buangsedikit ($content);
$xkon = explode('[(.Y.)]',$content, -1);
$ndex = ($post->ID + date(G)) % count ($xkon);
echo '<blockquote>'.$xkon[$ndex].'</blockquote>';
function buangsedikit($mbok) { /*remove words containing little characters */
$crot = explode('[(.Y.)]',$mbok, -2);
foreach ($crot as $cret) {
if (strlen($cret) > 100) {$mbal .= $cret.'[(.Y.)]';}
}
return $mbal;
}
?>