Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove viewport metatag from wordpress?

I looked everywhere but couldn't find a remove action for the viewport metatag from wp_head() in wordpress. Is it possible to remove it?

Found this article http://circlecube.com/2013/01/adding-viewport-meta-tag-via-wordpress-theme-functions/ which helped me to add my own, but now I have two tags...

Does anyone know how to do it?

like image 654
shapeshifta Avatar asked Oct 26 '25 07:10

shapeshifta


2 Answers

Comment out the line add_filter('wp_head', 'viewport_meta'); from your themes's functions.php

like image 99
Mithun Sreedharan Avatar answered Oct 29 '25 06:10

Mithun Sreedharan


Not sure how the accepted answer works. That filter won't work unless wrapped inside of a pre_get_posts action like so:

add_action('pre_get_posts', function() {
    remove_action('wp_head', '_block_template_viewport_meta_tag', 0);
});

The OP did not give the theme they use nor did they say they were using a block theme or not. But if using a block theme then this is the correct anser I believe. Source:

https://core.trac.wordpress.org/ticket/59510

like image 27
mrwpress Avatar answered Oct 29 '25 06:10

mrwpress



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!