Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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 xyz

    Thanks
    Tim

    #1369824

    Hey slikslok,
    WordPress offers this setting at WordPress ▸ Settings ▸ Reading ▸ Search engine visibility
    2022-10-22_012.png

    Best regards,
    Mike

    #1369825

    I know this, but I want this for explicit one single page, not the whole homepage!
    So not for domain.de but domain.de/id=23

    Is it clearer know?

    Thanks

    #1369827

    Something 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’);

    #1369829

    Hi,
    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);

    2022-10-22_016.png
    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,
    Mike

    #1369832

    Found 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);

    #1369835

    Hi,
    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.
    2022-10-22_019.png
    2022-10-22_020.png
    So the plugin is no help.

    Best regards,
    Mike

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.