Laney
Laney

Reputation: 3

Can PHP be inserted into a javascript call in my header?

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!

Upvotes: 0

Views: 282

Answers (6)

Luca
Luca

Reputation: 1118

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.

Upvotes: 0

markratledge
markratledge

Reputation: 17561

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.

Upvotes: 0

37Stars
37Stars

Reputation: 2499

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.

Upvotes: 0

belugabob
belugabob

Reputation: 4460

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?

Upvotes: -1

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146660

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

Upvotes: 0

Select0r
Select0r

Reputation: 12668

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.

Upvotes: 3

Related Questions