It shouldn’t really matter where in the <head>
a meta tag is positioned. If need to have it earlier, you can specify the priority. By default it is 10; by making it lower the hook will be executed earlier.
Here is a simpler code example with an early priority:
add_action( 'wp_head', function () { ?>
<meta name="author" content="John Doe">';
?> }, 1 );
In this example, anything between the top line and the bottom line will be included in the <head>
section. If you change the 1
on the bottom line, the content will appear lower in <head>
.
These two example use action hooks and anonymous functions. Searching for “WordPress action hooks” or “PHP anonymous functions” will bring up a lot of resources on the matter.