我已经在 WordPress 上创建了超过 10k 的页面,为了避免 Google 因内容稀薄而受到 Panda 惩罚,我所做的是将 JavaScript 代码放在 Loop-page.php 上,并检查页面是否没有内容并添加了元数据禁止抓取页面的标签,但它并不总是有效。这是我添加的代码。
<?php if($post->post_content=="") { ?>
<p>We are still updating our website with contents. Please check back next time.</p>
<script>
(function(){
var meta = document.createElement("meta");
meta.setAttribute("name", "robots");
meta.setAttribute("content", "noindex, nofollow");
document.head.appendChild(meta);
var meta2 = document.createElement("meta");
meta2.setAttribute("name", "googlebot");
meta2.setAttribute("content", "noindex");
document.head.appendChild(meta2);
})()
</script>
您能给我一个正确执行此操作的想法吗?当 Google 抓取页面时,我的 JavaScript 似乎无法运行,顺便说一句,我正在使用 SEO Ultimate 插件
当年话下