Support » Themes and Templates » Help: Adding meta tags with Wp_head

Viewing 4 replies - 1 through 4 (of 4 total)
  • can you send a URL to your website? and paste in the contents of your header.php file if it’s not too long or put it in http://pastebin.com/ if it’s quite long.

    The wp_head(); function – which runs the “wp_head” hook – is usually placed right before the closing </head> tag but in your case I think it’s placed right AFTER the opening <body> tag or something.

    just to notify me of followup emails

    Nope, wp_head is right before closing head.

    <!DOCTYPE html><html <?php language_attributes(); ?> class="<?php if (function_exists('css_browser_selector')) { echo css_browser_selector(); } else { echo 'off'; } ?>">
    <head>
        <title><?php wp_title( '|', true, 'right' ); ?></title>
        <?php d4_head(); ?>
        <?php wp_head(); ?>
    </head>
    <body <?php body_class(); ?>>

    You can see here, I’m currently trying to just echo the function straight in the the head with d4_head();. The Functions.php, no longer has the add_action and I get the same result, any ‘echo’ actually echoes inside the body tag…

    Currently, this is a barebones theme I’m developing and there is no live site to view.

    Ah, the trouble was with the bloginfo() function. The function itself doesn’t return, it echoes. So I was double echoing. I cleaned that up and it works perfectly.

    here’s the header.php (You can see the minimalistic file I was going for)

    <!DOCTYPE html><html <?php language_attributes(); ?> class="<?php if (function_exists('css_browser_selector')) { echo css_browser_selector(); } else { echo 'off'; } ?>">
    <head>
        <title><?php wp_title( '|', true, 'right' ); ?></title>
        <?php wp_head(); ?>
    </head>
    <body <?php body_class(); ?>>

    Here’s the function:

    function d4_head() {
    	echo '<meta charset="'; bloginfo( "charset" ); echo '" />' ;
    	echo '<link rel="profile" href="http://gmpg.org/xfn/11" />';
    	echo '<link rel="pingback" href="'; bloginfo( "pingback_url" ); echo '" />';
    	// Favicon
    	echo '<link rel="Shortcut Icon" type="image/x-icon" href="'.get_bloginfo('stylesheet_directory').'/img/favicon.ico" />';
    	// Jquery - Google, then wordpress's
    	if (!is_admin()) {
    		wp_deregister_script('jquery');
    		wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3', true);
    		wp_enqueue_script('jquery');
    	}
    	// Theme CSS
    	echo '<link rel="stylesheet" type="text/css" media="all" href="'.get_bloginfo( 'stylesheet_url' ).'" />';
    }
    add_action('wp_head', 'd4_head');

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help: Adding meta tags with Wp_head’ is closed to new replies.