大多數的情況下,我們都想讓百度儘快收錄文章。 但如果你想禁止搜尋引擎收錄特定的 WordPress 文章,就可以使用本文介紹的方法。
透過新增自定義欄目,防止百度和其他搜尋引擎收錄特定文章和頁面。
開啟主題 header.php 模板檔案貼上以下程式碼到<head> 和</head> 標籤之間:
<?php
    $noindex = get_post_meta($post->ID, 'noindex-post', true);
    if ($noindex) {
        echo '<meta name="robots" content="noindex,nofollow" />';
    }
?>
每當你想禁止搜尋引擎收錄特定文章和頁面時,只需為在編輯文章時新增一個自定義欄目名稱: noindex-post ,值:可任意,你的文章將不會被收錄。