Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

noindex

Function Description:

Displays a `noindex` meta tag if required by the blog configuration.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Prevent a specific page from being indexed by search engines
function noindex_specific_page() {
    if ( is_page( 'example-page' ) ) {
        echo '';
    }
}
add_action( 'wp_head', 'noindex_specific_page' );
// Example 2: Exclude a custom post type from search engine indexing
function noindex_custom_post_type() {
    if ( is_post_type_archive( 'custom_post_type' ) ) {
        echo '';
    }
}
add_action( 'wp_head', 'noindex_custom_post_type' );
// Example 3: Conditionally prevent indexing of a category archive page
function noindex_category_archive() {
    if ( is_category( 'example-category' ) ) {
        echo '';
    }
}
add_action( 'wp_head', 'noindex_category_archive' );