Tagged: meta tag
-
AuthorPosts
-
October 22, 2022 at 9:45 pm #1369823
Hi,
how can I change a meta-tag for one specific site, which should not be indexed and archived? In functions.php of the child-theme I guess, but how is the syntax?
Want to place a line like this: <meta name=”robots” content=”noindex, nofollow, noarchive”>, but only for a site with ID xyzThanks
TimOctober 22, 2022 at 10:01 pm #1369824October 22, 2022 at 10:34 pm #1369825I know this, but I want this for explicit one single page, not the whole homepage!
So not for domain.de but domain.de/id=23Is it clearer know?
Thanks
October 22, 2022 at 10:55 pm #1369827Something like this in the functions.php, but I don’t know the exact syntax:
function new_meta_tag() {
if (is_page (‘5408’)) {
??? (‘<meta name=”robots” content=”noindex, nofollow, noarchive”>’), ‘???’, false???);
}
}add_action(‘???’, ‘new_meta_tag’);
October 23, 2022 at 12:18 am #1369829Hi,
Thank you, I thought you meant for one “site”, I didn’t realize it was for one “page”
Anyway, if you add this function to your child theme functions.php it will add it to the page you choose, in this example I tested on the page 632 so change to your page.function custom_noindex_for_one_page(){ if ( is_page( 632 ) ) { ?> <meta name="robots" content="noindex, nofollow, noarchive"> <?php } } add_action('wp_head', 'custom_noindex_for_one_page', 1);
Please note that I found no way to remove or change the WordPress default robot meta tag, I tested many codes I found online but they all only added a second robot entry like my function does. I also tested a plugin noindex SEO in hopes of recommending it, but it also only added a second entry and didn’t allow you to choose a specific page.
So since adding a second robot meta tag seems to be the going solution you are welcome to use this.
If you find a better solution please share.Best regards,
MikeOctober 23, 2022 at 1:04 am #1369832Found something.
This Plugin deletes metatag robots:But how can I bring it back for all other pages except 632 like in your example?
Like this?
function custom_index_for_evry_page(){
if ( is_page( ) ) {
?>
<meta name=”robots” content=”index, follow”>
<?php
}
}
add_action(‘wp_head’, ‘custom_index_for_every_page’, 1);October 23, 2022 at 1:58 am #1369835Hi,
This plugin doesn’t remove the WordPress default robots meta tag, it only removes the wp_robots_max_image_preview_large meta tag. Read their explanation here.
So the plugin is no help.Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.