Hide “Exclude this image from sitemap”

#92865
  • Resolved mwkuiper
    Rank Math free

    My website uses the WordPress media uploader on the front end of the website. When users/visitors to my website upload media, the option “Exclude this image from sitemap” will be displayed. Is it possible to hide this from certain user roles or remove the option entirely in the WordPress media uploader?

    Screenshot: https://prnt.sc/uyahqi

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    To remove that option, please add the following code to the functions.php file of your child theme:

    add_filter( 'attachment_fields_to_edit', function( $form_fields, $post ) { unset( $form_fields['rank_math_exclude_sitemap'] ); }, 30, 2 );

    If you want this code to apply for users with (or without) specific capabilities, you can do something like this:

    add_filter( 'attachment_fields_to_edit', function( $form_fields, $post ) { if ( ! current_user_can( 'install_plugins' ) ) { unset( $form_fields['rank_math_exclude_sitemap'] ); } }, 30, 2 );

    With the code above, only users who can install plugins will be able to see the checkbox. You can find a list of the default capabilities here: https://wordpress.org/support/article/roles-and-capabilities/

    Hope that helps.

    Thanks!
    This solution has worked.

    Sajid Khan
    Rank Math business

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Hide “Exclude this image from sitemap”’ is closed to new replies.