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 custom_noindex() {
if (is_page('contact')) {
echo '';
}
}
add_action('wp_head', 'custom_noindex');
// Example 2: Exclude a custom post type from search engine indexing
function exclude_custom_post_type_from_indexing() {
if (is_singular('your_custom_post_type')) {
echo '';
}
}
add_action('wp_head', 'exclude_custom_post_type_from_indexing');
// Example 3: Conditionally add noindex tag to specific category pages
function exclude_category_from_indexing() {
if (is_category('uncategorized')) {
echo '';
}
}
add_action('wp_head', 'exclude_category_from_indexing');