如何阻止Algolia在Wordpress中使用noindex索引文章

如何阻止Algolia在Wordpress中使用noindex索引文章,wordpress,algolia,Wordpress,Algolia,我在我的网站gintlemen.com上使用Algolia,我不希望通过Yoast SEO插件设置为noindex的帖子被Algolia索引 我找到了这篇文章,但我不知道该把这个片段放在哪里 你能帮我一下吗?要排除Yoast标记为“noindex”的帖子,你需要在活动主题的functions.php中添加以下代码片段 <?php /** * Don't index pages where the robot index option * in the Yoast SEO plugin

我在我的网站gintlemen.com上使用Algolia,我不希望通过Yoast SEO插件设置为noindex的帖子被Algolia索引

我找到了这篇文章,但我不知道该把这个片段放在哪里


你能帮我一下吗?

要排除Yoast标记为“noindex”的帖子,你需要在活动主题的functions.php中添加以下代码片段

<?php
/**
 * Don't index pages where the robot index option
 * in the Yoast SEO plugin is set to noindex.
 *
 * @param bool    $should_index
 * @param WP_Post $post
 *
 * @return bool
 */
function filter_post( $should_index, WP_Post $post )
{
    if ( false === $should_index ) {
        return false;
    }

    return get_post_meta($post->ID, '_yoast_wpseo_meta-robots-noindex', true) == 1 ? false : true;
}

// Hook into Algolia to manipulate the post that should be indexed.
add_filter( 'algolia_should_index_searchable_post', 'filter_post', 10, 2 );
add_filter( 'algolia_should_index_post', 'filter_post', 10, 2 );

要排除Yoast标记为“noindex”的帖子,需要将以下代码段添加到活动主题的functions.php中

<?php
/**
 * Don't index pages where the robot index option
 * in the Yoast SEO plugin is set to noindex.
 *
 * @param bool    $should_index
 * @param WP_Post $post
 *
 * @return bool
 */
function filter_post( $should_index, WP_Post $post )
{
    if ( false === $should_index ) {
        return false;
    }

    return get_post_meta($post->ID, '_yoast_wpseo_meta-robots-noindex', true) == 1 ? false : true;
}

// Hook into Algolia to manipulate the post that should be indexed.
add_filter( 'algolia_should_index_searchable_post', 'filter_post', 10, 2 );
add_filter( 'algolia_should_index_post', 'filter_post', 10, 2 );