Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have Twitter's own widget set to load on a website, which works just fine. However, on my WP-powered blog the script is included but not rendered. I call it inside an empty div like this:

<?php include $_SERVER['DOCUMENT_ROOT'].'/twtr-widget.html' ?>

But it appears in the page source as HTML (I'm putting '...' to save room):

<script src="http://widgets.twimg.com/j/2/widget.js"></script> 
<script> 
new TWTR.Widget({...
...</script>

In other words, the script is not being executed. Why is this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You cannot process Javascript with the PHP interpreter - the PHP interpreter will ignore anything which is not bound by <?php/?> and will simply return the include as part of the document you are serving.

share|improve this answer
    
I thought this to be the case as well, yet putting the Javascript straight into the template yields the exact same result. Any other ideas? –  Isaac Lubow Dec 24 '10 at 16:50
    
@Isaac Lubow What happens when you load the page with the widget script included? Do you see any Javascript errors? –  danlefree Dec 24 '10 at 23:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.