Is there any way to add tags to the <head> section in WP?

Vadim Cherepenichev asked
wordpress plugins seo
via

I develop a plugin and need to add meta tags to the section.

I have spent about 1 hour and had found a lot of hooks, but all of them are bypasses. I don’t want to turn my code in piece of ****, can sb tell me if there is normal way to add html to the ?

Thank you


Answer
via

The standard is to use the wp_head hook.

<?php
add_action( 'wp_head', function() {
    echo '<meta ... />';
} );

Note: This works well for meta tags. However, if you’re injecting styles or scripts, instead of printing those out yourself using wp_head, use wp_enqueue_script() or wp_enqueue_style().

Share This
Posted in: