Skip to content

mistweaverco/wp-robots-noindex

production
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

WP-Robots-NoIndex

A WordPress-Plugin for flagging individual pages and/or posts, so they will output a <meta name="robots" content="noindex" /> tag.

This tells the search-engines not to index you page/post.

Coverage

This plugin is thoroughly tested using PHPUnit.

Installation

Go to your WordPress installation directory, then change to wp-content/plugins.

Then either run (the preferred way):

git clone \
https://github.com/superevilmegaco/wp-robots-noindex.git \
-b v3.0.1 \
wp-robots-noindex

or (no easy updating via git or git submodules) download the latest release from here and unzip its contents to wp-content/plugins/wp-robots-noindex.

Then head over to www.your-wordpress-installation-domain.tld/wp-admin/plugins.php and activate the plugin.

Usage

If you don't tick the checkbox (this is the default), it'll output a <meta name="robots" content="index,follow"/> tag, which tells the search-engines to index your post/page and follow all the links.

If you happen to have a completely customized theme, you can simply call this function

<?php
        robotsnoindex_display_meta_tag();
?>

Defaults

This will result in

<meta name="robots" content="index,follow"/>

If neither the Robots: NoIndex, nor the Robots: NoFollow checkboxes have been ticked.

NoIndex

If the Robots: NoIndex checkbox has been checked, but not the Robots: NoFollow checkbox, robotsnoindex_display_meta_tag(); will produce the following output:

<meta name="robots" content="noindex,follow"/>

NoFollow

If the Robots: NoFollow checkbox has been checked, but not the Robots: NoIndex checkbox, robotsnoindex_display_meta_tag(); will produce the following output:

<meta name="robots" content="index,nofollow"/>

NoIndex, NoFollow

If both the Robots: NoFollow and Robots: NoIndex checkboxes have been ticked, robotsnoindex_display_meta_tag(); will produce the following output:

<meta name="robots" content="noindex,nofollow"/>

Advanced Usage

If you don't want to produce any output, but want to check for the current status of the post, you can simply call robotsnoindex_get().

<?php
$noindex = robotsnoindex_get(ROBOTSNOINDEX_NOINDEX);
$nofollow = robotsnoindex_get(ROBOTSNOINDEX_NOFOLLOW);
if ($noindex) {
        // noindex is set for this post/page
} else {
        // noindex is NOT set for this post/page
}
if ($nofollow) {
        // nofollow is set for this post/page
} else {
        // nofollow is NOT set for this post/page
}
?>

About

WordPress Plugin: Ask search engines not to index individual pages by checking an option in the publish post box.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published