views:

112

answers:

7

I have a wordpress theme that I like to duplicate. To make things easier on myself I'm trying to use the bloginfo function to call my jquery file..like this:

<script type="text/javascript" src="<?php echo bloginfo("template_url"); ?>/js/jquery-1.4.2.min.js"></script>

I just can't get it to work. When I check my source file it looks exactly like the code above.

Can this even be done? Or should I just forget it? Thanks guys!

A: 

For sure the problem is not in the PHP or JavaScript but in the way you print that line of code. Can you paste more code that will help finding the problem?

stoimen
I'm not the down vote, but can you please stop linking to your blog in every answer?
Tom
blog link removed.
Michael Petrotta
+3  A: 

Are you sure the above code is actually in a PHP-file and gets parsed by the server? I can't think of a different reason why PHP-code should just be printed and not executed.

Select0r
I'm not sure. I use the thesis theme and they have an option to add code to the header or footer. It works fine when I type out the whole url, like: <script type='text/javascript' src='http://www.mysite.com/wp-content/themes/thesis_16/js/jquery-1.4.2.min.js'></script>I could just stick with this method, but was hoping to use the bloginfo shortcut.
Laney
The code you add via the theme options (in this case) does not get processed by PHP.
Bart van Heukelom
Thanks, I figured it had to do with the theme. No biggee - I'll just do it the old fashinoned way. Thanks for all the help people!
Laney
A: 

See the Referencing Files From a Template chapter in http://codex.wordpress.org/Theme_Development

Álvaro G. Vicario
A: 

As I've never used PHP, this is only a guess...

PHP is a server side language, and you're tyring to use it on the client side?

belugabob
A: 

Whats the name of this file? It should end in .php.

What does the source look like when you view it from the browser?

Are there other places in the file where you use and is that data correct?

Make sure there are no blank lines at the end of the source file. PHP doesn't like blanks lines at the end of the code.

37Stars
A: 

You should try to edit your theme's header.php file directly because custom fields of your theme may not be executed by PHP interpreter.

neon
A: 

Two problems: No need for the echo in the WP template tag; should be

<?php bloginfo("template_url"); ?> Template Tags/info « WordPress Codex

And, why are you trying to include jQuery from the template directory, when it resides in wp-includes/js? You should be using Function Reference/wp enqueue script, if your theme doesn't already include jQuery.

songdogtech