How to noindex nofollow custom post type?
Answering my own question here: The WordPress SEO plugin provides a menu for all posts and pages, including custom post types, that includes noindex and nofollow options.
Answering my own question here: The WordPress SEO plugin provides a menu for all posts and pages, including custom post types, that includes noindex and nofollow options.
One part of removing your site from Google is to add <meta name=”robots” content=”noindex,follow” /> to every page. If you can edit the theme code then you could just add this to header.php (and any variants). You could also use a plugin. I’ve not tested any, but https://wordpress.org/plugins/simple-robots-meta/ claims to do the job simply.
Use in your .htaccess: Options -Indexes … to disable directory listings. See the Apache manual for details. To restrict the access just to two URLs you might use: RedirectMatch 204 ^/wp-content/$ RedirectMatch 204 ^/wp-content/dir/$ 204 is the No Content response. Very fast. 🙂
Extending @prosti answer, WordPress add it using action login_head in wp-login.php itself. add_action( ‘login_head’, ‘wp_no_robots’ ); You can remove this action in theme/plugin and add your own action with custom callback function. Example:- //Keep priority 9 so we can remove WordPress action that is on 10 add_action( ‘login_head’, ‘custom_no_robots’, 9); /** * Custom robot tags … Read more
This is how I would do it : 1/ create a filter to access the post content before it’s displayed on page. See http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2/ Inside your fonction called (ie : my_the_content_filter in the example from the Codex) adapt this code : https://stackoverflow.com/questions/5037592/how-to-add-rel-nofollow-to-links-with-preg-replace Cheers !
Assuming you are targetting links in post content, I’d say something like that : add_filter( ‘the_content’, ‘wpse_254317_nofollow’ ); /** * Add rel nofollow according to a predefined domain * to links in content * @param $content * @link http://stackoverflow.com/a/4809181/1930236 * @return mixed */ function wpse_254317_nofollow( $content ) { $my_folder = “https://google.com”; preg_match_all( ‘~<a.*>~isU’, $content, $matches … Read more
The E flag is being used for LiteSpeed as opposed to ENV for Apache. Where did you get this from? The LiteSpeed docs appear to show that LiteSpeed is the same as Apache in this respect and require env=, not E=, on the Header directive in order to conditionally set the HTTP response header based … Read more
you can add a filter in your functions.php add // Nofollow in content add_filter(‘the_content’, ‘my_nofollow’); function my_nofollow($content) { //return stripslashes(wp_rel_nofollow($content)); return preg_replace_callback(‘/<a[^>]+/’, ‘my_nofollow_callback’, $content); } function my_nofollow_callback($matches) { $link = $matches[0]; $site_link = get_bloginfo(‘url’); if (strpos($link, ‘rel’) === false) { $link = preg_replace(“%(href=\S(?!$site_link))%i”, ‘rel=”nofollow” $1’, $link); } elseif (preg_match(“%href=\S(?!$site_link)%i”, $link)) { $link = preg_replace(‘/rel=\S(?!nofollow)\S*/i’, ‘rel=”nofollow”‘, … Read more
functions.php: function remove_nofollow($link, $args, $comment, $post){ return str_replace(“rel=”nofollow””, “”, $link); } add_filter(‘comment_reply_link’, ‘remove_nofollow’, 420, 4);
wp_rel_nofollow() add nofollow attribute to all links so we can not use it or may be I am not sure how. You can use this function to add rel=”nofollow” to all external links. This function will check all links in content against your blog/website URL (as internal domain) and add nofollow attribute if both does … Read more