• Resolved dlowder

    (@dlowder)


    I have an issue with the Yoast plugin, where adding the following to the function.php doesn’t remove the canonical link Yoast generates.

    https://developer.yoast.com/features/seo-tags/canonical-urls/api
    add_filter( 'wpseo_canonical', '__return_false' );

    I’d like to remove all canonical links from everyone of my WP pages (Not posts).

    In addition, I have another filter in my function.php file that removes the schema Yoast generates, which works. I’m completely lost to why the canonical filter doesn’t work.

    Any help would be very much appreciated!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @dlowder,

    Thank you for reaching out.

    We used the same filter on a local environment where we just added the filter in the functions.php file of the default TwentyTwenty theme and that worked on our side. If you want this to only happen for a specific post type, you would need to have conditions for it running in a function. Can you please tell us why you would disable the canonical on pages only and not for posts?

    Thread Starter dlowder

    (@dlowder)

    @jeroenrotty

    We have 2 different Kinsta instances where one instance is for the Jane Blog and the other is a way for our Marketing team to create custom landing pages without the need of a Dev team. For the instance I want to disable the canonical, we’re not using the posts page type.

    We’re using WP as a CMS and pager builder for creating custom landing pages where I’m manually adding canonical through each page’s headers. Because we have a reverse proxy setup the WP site address setting is on a different domain then what the public sees. If I change this setting the canonical that’s generated by Yoast shows correctly but breaks WP and won’t allow for any new pages or save changes through the admin to happen. (The reverse proxy isn’t in the best setup either currenty.) The canonical link is the only thing I want to manually setup but I’m trying to avoid 2 canonical links that point to 2 different domains.

    It’s possible that our custom WP theme is missing something for this filter to work. Thoughts?

    PS I should mention that I did try updating each page’s canonical link through the Yoast setting but the link won’t change or isn’t impacted by the setting at all.

    • This reply was modified 4 years, 9 months ago by dlowder.
    • This reply was modified 4 years, 9 months ago by dlowder.
    Plugin Support Md Mazedul Islam Khan

    (@mazedulislamkhan)

    We are afraid to say that it’s very hard for us to confirm anything without taking a look at your setup that whether your custom theme is missing anything that causes the issue for you.

    That said, there shouldn’t be anything that might prevent the relevant filter to work on your site. We have tested the relevant filter again on a fresh WordPress installation and can confirm that it’s working fine as expected.

    Hi @dlowder ,

    We’re closing this thread because we haven’t heard back from you in a while. Should you have further questions, please open a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Removing the canonical link Yoast generates’ is closed to new replies.