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

Basic PHP Question for Theme Functions WordPress

  • SOLVED

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="http://validator.w3.org/check?uri=http%3A%2F%2Flucaswynne.com%2F547-2%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.1"]]http://validator.w3.org/check?uri=http%3A%2F%2Flucaswynne.com%2F547-2%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.1[[/LINK]]

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

Answers (3)

2011-01-14

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" />';

2011-01-14

Baki Goxhaj answers:

Here:

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

2011-01-14

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');