Nofollow allows search engines to visit your page/post. Whether they index your site or not, depends on the “noindex” tag. When search engines see the “nofollow” tag (independent of “noindex”) they will not browse through the links on that page. They don’t even bother where those links connect. Hence when you add the “nofollow” tag, the backlinks on your site will not be considered. This may affect SEO.

Here in this article will be adding “nofollow” links to specific pages and posts without using any plugins. Let me know in the comments whether you landed here after testing all available methods with robots.txt!. Obviously, you couldn’t find a way to “nofollow” through robots.txt and thats why you are here 🙂
I have already added an article on how to NoIndex Specific Posts & Pages in WordPress without Plugin
If you read the mentioned article, you will understand the core basics which I have not repeatedly explained here. Probably, you won’t land here back. 🙂
You can add “nofollow” ONLY tag to the meta or, together with a “noindex” meta tag. You can also add a “noindex” tag independently. This requires a better understanding of how robots meta work and that’s a whole different concept.
In all these below examples, we use WordPress conditional tags to specify which post/ page we are targeting. Add this below PHP to your child theme’s functions.php or through the code snippets plugin.
Table of Contents
Nofollow Specific WordPress Post
/* No Follow and No Index Our Test Post- wpclimax.com/test-post/ */
add_action('wp_head', 'wpclimax_header_function_condition_noindex_nofollow_post_single');
function wpclimax_header_function_condition_noindex_nofollow_post_single(){
if ( is_single( '1889' ) ) { ?>
<meta name="robots" content="nofollow" />
/* What we Use for out Test Post */
/* <meta name="robots" content="noindex, nofollow" /> */
<?php }
};
In our case, for our Test Post, we have added both Noindex and Nofollow tags.
Nofollow Multiple WordPress Posts
/* No Follow Multiple Posts- wpclimax.com */
add_action('wp_head', 'wpclimax_header_function_condition_nofollow_post_multiple');
function wpclimax_header_function_condition_nofollow_post_multiple(){
if ( is_single( array( '3241', '3243') ) ) { ?>
<meta name="robots" content="nofollow" />
<?php }
};
Both, the above codes, 3241, 3243 are Post IDs. Remove which we have added and enter the correct ones.
Nofollow Specific WordPress Page
Replace the is_single() function with is_page(). Don’t keep it empty or else, every single page of your site will be “nofollow”ed. Here we have added “nofollow” tag to About Us page as an example. Instead of entering the page ID, we can also use the ‘slug‘.
/* No Follow Links on About Page */
add_action('wp_head', 'wpclimax_header_function_condition_nofollow_page_single');
function wpclimax_header_function_condition_nofollow_page_single(){
if ( is_page( 'about' ) ) { ?>
<meta name="robots" content="nofollow" />
<?php }
};
Nofollow Home Page/ Front Page.
If you are targetting the front page of your website, you can use the below code. Don’t get confused. The home page in WordPress refers to the posts archive page. You can set your front page as a custom page or as a post archive.
/* No Follow Links on Front Page */
/* You DON'T DO this. This is just an example */
add_action('wp_head', 'wpclimax_header_function_condition_nofollow_page_front');
function wpclimax_header_function_condition_nofollow_page_front(){
if ( is_front_page() ) { ?>
<meta name="robots" content="nofollow" />
<?php }
};
If you use is_home(), then that will affect only the ‘All Post Archive‘ page and not for the FrontPage of your site. If the FrontPage is itself set to Show Post Archives, it works.
Nofollow Multiple WordPress Pages
/* No Follow Multiple Posts- wpclimax.com */
add_action('wp_head', 'wpclimax_header_function_condition_nofollow_page_multiple');
function wpclimax_header_function_condition_nofollow_page_multiple(){
if ( is_page( array( '3242', '3244', '3245', '3246') ) ) { ?>
<meta name="robots" content="nofollow" />
<?php }
};
Nofollow Affiliate Pages
If you are using Affiliate links on a specific page, and you want Search Engines to “nofollow” the links on such pages, use the below code.
In this case, assuming the Affiliate Link page has slug ‘affiliate-page’, the below code will work. Or else, use the Page ID. If there are multiple Affiliate Pages, add them in an array. Also shown in the same code.
/* No Follow Links on Affiliate Page */
add_action('wp_head', 'wpclimax_header_function_condition_nofollow_page_affiliate');
function wpclimax_header_function_condition_nofollow_page_affiliate(){
if ( is_page( 'affiliate-page' ) ) { ?>
<meta name="robots" content="nofollow" />
<?php }
};
/* For Multiple Affiliate Pages use page IDs and below line Instead of above one */
if ( is_page( array( 'affiliate-page' , 'affiliate-page-2', 'page ID' ) ) ) { ?>
/* If Affiliate Post is to be nofollowed, use is_single() tag */
If you have something specific to “noindex” or “nofollow”, let us know in the comments below. We would like to take it a try.