Help: Adding meta tags with Wp_head
-
My goal: Add in meta tags to a theme’s header through the function file.
Why?: Only reason is for my sake, keeping the header.php fairly clean and using functions to put in the stuff I’d rather not think about.my code:
function d4_head() { echo '<meta charset="' . bloginfo( "charset" ) . '" />' ; echo '<link rel="profile" href="https://gmpg.org/xfn/11" />'; echo '<link rel="pingback" href="' . bloginfo( "pingback_url" ) . '" />'; // Favicon echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/img/favicon.ico" />'; // Jquery - Google's if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3', true); wp_enqueue_script('jquery'); } } add_action('wp_head', 'd4_head');
Problem: What actually happens is that it puts it right at the very top of the page, in the body tag, not the head.
Research: I’ve read that echoing into the WP-head is not best practice and in my case, doesn’t work at all. ‘Return’ doesn’t work.
I found wp_enqueue_script will work fine for CSS & Javascripts… however the remaining is the meta data.
I’ve also tried adding
<?php d4_head; ?>
into the head itself, but alas… nothing.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Help: Adding meta tags with Wp_head’ is closed to new replies.