WordPress wp_head – how to remove link canonical and api?

How can I remove these two links from the WP header?

<link rel='https://api.w.org/' href='http://xxx/wp-json/' />
<link rel="canonical" href="http://xxx/" />

I don’t know what they are for. They just look redundant to me.

Read More

Is it possible?

Related posts

1 comment

  1. Meta rel="canonical" is printed by rel_canonical function, plugged into wp_head action in wp-includes/default-filters.php (line 237 in WP 4.4), so

    remove_action( 'wp_head', 'rel_canonical' );
    

    should do it.

    For api (also plugged in that file, line 213) the code would be

    remove_action( 'wp_head', 'rest_output_link_wp_head' );
    

    I don’t know what the api meta means, but I’m quite sure that canonical should help you with SEO.

Comments are closed.