• Resolved Natalya

    (@nalitana)


    Hello! At the very beginning of using the plugin, I enabled redirecting attachments to the post in which they are published, but now I need to disable redirection. Further, in the plugin settings on the “Attachments” tab, I marked the robots meta tags “nofollow, noindex, noarchive, noimageindex, nosnippet”, but these parameters are displayed only for attachments loaded after changing the settings. All old attachments have “follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large” meta tags. Resaving and deactivating the plugin does not help. Then, I decided to completely disable the robots meta tag on the “Attachments” tab and add it to the attachment pages through the function, but this also did not work. If you click disable, the meta tag will again display “follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large”. How do I enable “nofollow, noindex, noarchive, noimageindex, nosnippet” for older attachments, or disable the robots meta tag entirely on these pages so I can add it manually? Help, please, now Google will index everything, but I don’t need it.

    • This topic was modified 1 year, 10 months ago by Natalya.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Natalya

    (@nalitana)

    Settings screenshot. Installed the latest version of the plugin and WP.

    Thread Starter Natalya

    (@nalitana)

    Now I checked, it turns out that the parameters do not change for all attachments published before 01/31/2020

    Thread Starter Natalya

    (@nalitana)

    Until you answered me, I did this:

    add_action( 'wp_head', 'rankmath_disable_features', 1 );
    function rankmath_disable_features() {
    if(get_post_mime_type()!= false) {
    remove_all_actions( 'rank_math/head' );
    }
    }

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @nalitana,

    Thank you for contacting the support.

    The robots meta option should be applied to all the attachment pages. Can you please confirm if you have the access to the meta box when editing an attachment page? If yes, then you must have changed the robots settings for the affected attachment pages manually and that’s why the global settings are not working for those pages.

    You can change the settings using the meta box for the affected pages or use the following filter:

    add_filter( 'rank_math/frontend/robots', function( $robots ) { if(is_attachment()) { $robots = ['index' => 'noindex', 'follow' => 'nofollow', 'imageindex' => 'noimageindex', 'archive' => 'noarchive' ]; return $robots; } return $robots; });

    Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Let us know if you need any other assistance.

    Thread Starter Natalya

    (@nalitana)

    Hello! Thank you very much for your time! Yes, I have access to all plugin settings. I understand what you are talking about. The fact is that for old attachments that were uploaded before 01/31/2020, the settings will not be applied in both cases: the global “noindex” does not work when the robots meta option on the “Attachments” tab is disabled; and individual settings on the “Attachments” tab do not work when the meta option on this tab is enabled. Everything uploaded after the above date has the robots attributes (nofollow, noindex, noarchive, noimageindex, nosnippet) that I applied in the plugin settings. Whether it’s the global meta option or the one on the “Attachments” tab, the settings work for those files. I also want to say that I did not make changes to media files manually, because. attachment forwarding was initially enabled. Unfortunately, I cannot understand the reason for this behavior.
    But the code you sent me helped me. All attachment pages now have the correct attributes. Thank you!

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @nalitana,

    Disabling the robots meta option in the global settings doesn’t disable the robots tag. It just disables the robots settings for the post type and the posts will take the robots value from the Global Meta settings or the robots settings of the meta box.

    Since the filter is working fine for you, there is nothing to be worried about as it will not be affected by any settings and will set all your attachment pages as Noindex.

    Hope that helps.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to make old attachments noindex, nofollow’ is closed to new replies.