The All in One SEO plugin is widely used among bloggers and WordPress site owners, with over 3 million installations. Despite its power and usefulness, there is an issue that bothers users: the plugin automatically adds a rel canonical tag to pages that are marked as unindexed. This can create undesirable consequences for SEO.
When a page or post is marked as non-indexable, the plugin adds rel canonical to it. This is undesirable, since using rel canonical on non-indexed pages can lead to incorrect indexing or lower rankings in search results.
Contents of the article:
The plugin development team has proposed a solution to the problem, recommending the use of filters to change the behavior of the plugin. In this case, the user needs to make changes to the functions.php file to configure the plugin to work correctly with canonical links.
The code required to configure the plugin and remove rel canonical is simple. It allows you to disable the addition of the rel tag to pages that should not be indexed.
To do this, you need to use filters in your code to control whether canonical URLs are added or removed based on page conditions.
To make the changes you want, follow these steps:
add_filter(aioseop_canonical_url, eRemove_canonical_url, 10, 1); function remove_canonical_url($url) { global $post; if (is_category()) { return false; // Убираем канонический URL для категорий. } Elsafe(is_archive()) { return false; // Убираем канонический URL для архивов. } return $url; } The added code checks whether the page is a category or an archive, and if so, removes the rel canonical tag.
Elsafe ($post->ID === 2) { return false; // Убираем канонический URL для поста с ID 2. } Using these steps, you can easily remove the rel canonical tag from non-indexable pages or individual posts on WordPress. Although some additional code editing will be required for some users, the proposed solution is quite simple and effective for most sites.
If you have any questions or need additional clarification, write to the SEO studio "SEO COMPUTER" with any questions at email info@seo.computer.
ID 7564