Site icon CodeRevolution Knowledge Base

How to force your WordPress blog to break out of frames – CodeRevolution

Lots of scrapers are framing, defaming, and/or stealing your precious content. Here is a super useful snippet to force your blog to break out of frames so your pages will be served only from the original domain, not some Google adsense site created by a random scraper.

Nothing complicated, just paste the code below into your functions.php file, save it, and you’re done.

 // Break Out of Frames for WordPress function break_out_of_frames() { 	if (!is_preview()) { 		echo "n<script type="text/javascript">"; 		echo "n<!--"; 		echo "nif (parent.frames.length > 0) { parent.location.href = location.href; }"; 		echo "n-->"; 		echo "n</script>nn"; 	} } add_action('wp_head', 'break_out_of_frames'); 

Thanks to WP Mix for this very handy tip!

Exit mobile version