Hot answers tagged

4

Thought this was a great question so I went digging. In default-filters.php on line 208 there's add_action('wp_head', 'noindex', 1); as of WordPress 4.1. The noindex() function in turn checks to see if you have set blog_public option to 0. If you have, it calls wp_no_robots() which is simply: function wp_no_robots() { echo "<meta name='robots' ...


3

Within the pages "Wordpress SEO by Yoast" meta box, open the "Advanced" tab and set the "Meta Robots Index". It took me forever to find this as well.


3

Ooohhh you mean "pagination" pages. Gotcha now! It's hard to say for sure(I know I know), but at first glance it looks like this block of code would be what you're after: if ( $wp_query->query_vars['paged'] && $wp_query->query_vars['paged'] > 1 && isset( $options['noindex-subpages'] ) && $options['noindex-subpages'] ) { ...


3

I would normally ask a couple clarifying questions but I don't have the reputation to do it so let's see if I can give you a workable solution. I don't know what you consider to be high quality but if it is certain fields being complete, you could do an if/else statement around those fields being set. Let's say you have fields created in the user profile ...


2

I suppose this ended up working for me. I was more hoping for some kind of better filter but it works just as well. Throw this in a functions.php file and you're good to go. /** No Index No Follow Entire Website **/ function nofollow_meta() { echo "<meta name='robots' content='noindex,nofollow' />\n"; } add_action( 'wp_head', 'nofollow_meta', 1 ); ...


2

I think not. Because it's not indexing the result page: See: <?php if (is_search()) { ?> if is Search doesn't index or follow the page (for example to not show duplicated content). But you can remove the code if you feel you are losing views. I was reading an article about this. Even if WordPress doesn't generate the /s=X page automatically, some ...


2

This won't ever return true: if ( is_single( '404.php' ) ) {} The is_single() conditional only returns true in a single blog post context. The parameter it accepts is a post ID, slug, or title. The 404.php file is a template file, not a post. Use is_404() instead: if ( is_404() ) {}


2

If it is because of SEO and the warnings in the Google Search console, these can be ignored. wp / Page2 and so on should still be indexed. The this answer and the article with the answer from google: For a while, SEOs thought it might be a good idea to add a noindex robots meta tag to page 2 and further of a paginated archive. This would prevent people from ...


2

As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using get_the_category As the OP stated he was using YOAST, i'll wrap this function into the YOAST hook for robots. add_filter('wpseo_robots', 'yoast_no_home_noindex', 999); function yoast_no_home_noindex($string= "") { $term_id = ...


2

By noindex, I'm assuming you mean meta robots noindex, if so you could manually do this by utilizing the in_category function adding the following to your theme's header between the <head></head> tags, like so:: <?php if(in_category( '92' )) echo "\t<meta name='robots' content='noindex, nofollow' />\r\n" ?> Or, If you don't ...


1

From codex: is_author() is a conditional tag which determines whether the query is for an existing author archive page. so it does not work for your scope. Best solution, instead of using the template file header.php is to write a function in functions.php hooking the proper action wp_head: add_action('wp_head','AS_exclude_author_from_indexing'); function ...


1

Being excluded-cat and excluded-cat-1 the categories you want to exclude from indexing: add_action('wp_head','AS_exclude_category_from_indexing'); function AS_exclude_category_from_indexing(){ $html=""; if(has_category('excluded-cat') || has_category('excluded-cat-1')){ $html= "<meta name=\"robots\" content=\"noindex,follow\">".PHP_EOL; } ...


1

The function you want is get_userdata(). Since you need to do this outside the loop, the process is a little less straight-forward. The first thing you need to do is set up a variable called $curauth which is an object that you create by accessing the database by using the $_GET[] superglobal. $curauth = ( isset( $_GET[ 'author_name' ] ) ) ? get_user_by( '...


1

After the question's update, I think that you need to set the canonical URL: add_action( 'wp_head', 'cyb_search_results_canonical_URL' ); function cyb_search_results_canonical_URL() { if( is_search() ) { $link = get_search_link(); echo '<link rel="canonical" href="' . esc_url( $link ) . '">'; } } And your problem with ...


1

This is a bit of a guess but there is a setting in the backend that will discourage indexing. Make sure that is not checked.


1

Go in your header.php and add the following snippet where you want your tag to appear: <?php if( 'your-post-type' === get_post_type() ){ print '<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'; } ?> get_post_type() will return the current post type.


1

Writing a robots.txt is an easy process. Follow these simple steps: Open Notepad, Microsoft Word or any text editor and save the file as 'robots,' all lowercase, making sure to choose .txt as the file type extension (in Word, choose 'Plain Text' ). Next, add the following two lines of text to your file: User-agent: * Disallow: 'User-agent' is another ...


Only top voted, non community-wiki answers of a minimum length are eligible