WordPress Plugin to Add Meta Robots Tag

The following is a simple way of adding a meta robots tag to a WordPress based site through a plugin. In this instance, the meta robots tag sets the “noimageindex” value to prevent site images from being indexed. Add the below code to a .php file and upload it to your plugin directory. Once uploaded, activate the plugin from your dashboard and the meta robots tag will be included in the site’s pages. As an alternative to this plugin based approach, the meta robots tag could also be added to a theme or child theme depending on your preference for customizing your site.

Plugin Name: WP Meta Robots Plugin
Plugin URI: https://www.dalesandro.net/
Description: WordPress plugin to add a basic meta robots tag to header.
Version: 1.0
Author URI: https://www.dalesandro.net/

function add_meta_robots_tag() {
  echo '<meta name="robots" content="noimageindex" />'."n";
add_action('wp_head', 'add_meta_robots_tag');

Leave a Comment