Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Basic PHP Question for Theme Functions WordPress


I am attempting to call a PHP sylesheet in WP functions. I have two pieces of code that need to call a specific stylesheet named tagmap.css

echo '<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/tagmap.css" type="text/css" media="screen" />';

Here is what XHTML validator says:
[[LINK href=""]][[/LINK]]

Be the first to fix it and you'll get your money.

Answers (3)


Chris Bavota answers:

Note that <em>bloginfo("template_url")</em> is deprecated. You should use <em>get_template_directory_uri()</em>.

So your snippet should look like this:

echo '<link rel="stylesheet" href="'.get_template_directory_uri().'/tagmap.css" type="text/css" media="screen" />';


Baki Goxhaj answers:


echo '<link rel="stylesheet" href="' . bloginfo("template_url") . ' /tagmap.css" type="text/css" media="screen" />';


Pippin Williamson answers:

You shouldn't do it that way. Use the built-in WordPress function to include a style sheet:

wp_enqueue_style('tagmap-styles', get_template_directory_uri() . '/tagmap.css');