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 search engines from indexing a specific page
function custom_noindex() {
if (is_page('example-page')) {
echo '';
}
}
add_action('wp_head', 'custom_noindex');
// Example 2: Exclude a category archive page from search engine indexing
function exclude_category_noindex() {
if (is_category('example-category')) {
echo '';
}
}
add_action('wp_head', 'exclude_category_noindex');
// Example 3: Avoid duplicate content issues by noindexing paginated pages
function noindex_paginated_pages() {
global $wp_query;
if ($wp_query->max_num_pages > 1 && is_paged()) {
echo '';
}
}
add_action('wp_head', 'noindex_paginated_pages');