• I just moved from Blogger to hosting a WordPress blog on my own domain. The import worked well and I’m wildly impressed. <br/><br/>

    I’d altered my Blogger template a lot, and I’d like to carry some of the changes over to wordpress. In particular there is a javascript that takes a random picture off my flickr site and inserts it in the header and at the end of each post. (eg https://acid-test.blogspot.com/) When I tried to insert the same script into page.php nothing happens. (eg https://www.greenglim.com/acid-test/ ) <br/><br/>

    All I’m capable of with scripting is following somebody else’s work exactly. Can somebody tell me what I need to type, and where to type it, to get the following script to work? I’d really, REALLY be grateful!<br/><br/>

    (from Ethan Zuckermann’s site: My Heart’s in Accra)
    <sc*ri*pt type=”text/javascript”>
    <*!–

    flickr_badge_background_color = “#FFFFFF”;
    flickr_badge_border = “0px solid #FFFFFF”;
    flickr_badge_width = “0px”;
    flickr_badge_height = “150px”;
    flickr_badge_text_font = “0px Verdana, Arial, Helvetica, Sans serif”;
    flickr_badge_image_border = “0px solid #000000”;
    flickr_badge_link_color = “#000000”;

    //–>
    </scr*ipt>
    <scr*ipt type=”text/javascript” src=”https://www.flickr.com/badge_code.gne?nsid=90884061@N00&count=2&display=random&name=0&size=square”></scr*ipt&gt;

    (nsid changed, in case it’s a bad idea to post those. ??) I’ve been all over the forums and docs looking for an answer, but either it’s staring at me and I don’t see it, or it’s not there. This is my first post here, so apologies if the formatting is messed up. (No preview button!)

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter quixote7

    (@quixote7)

    Followup: The script works when I just write a web page and put it in. It works on Ethan’s site (https://www.ethanzuckerman.com/blog/) which, it turns out, is a WordPress blog. On my site, I can’t even get a simple “hello, world” javascript to run, no matter where I put it: header.php, page.php, sidebar.php. The only thing that shows up is straight text, and in header.php sometimes not even that.

    What could my js problem be? As far as I can tell, I’m entering the script correctly according to the wordpress codex javascript docs. I have rich text editor turned off (although it’s already off when editing templates, in any case). As far as I can tell, I have the path to the script correctly set, and the file is read and execute enabled. Is javascript globally turned off somewhere, and do I need to turn it on?

    Help, please! This is driving me crazy!

    Thread Starter quixote7

    (@quixote7)

    Followup #2: moshu, thanks for your response. I didn’t see it earlier. Unfortunately, no, that doesn’t help. I’m obviously doing something wrong, but I can’t figure out what.

    Thread Starter quixote7

    (@quixote7)

    Embarrassing resolution:

    Turned out javascript was turned off. But not at WordPress. On my browser. Jeeeee-sus.

    The good news is: the documentation works.

    I’ve got google and other assorted js all over various client blogs, and it all works fine. The only thing I see different from any of those comparing yours is that I surround the scripts with CDATA tagsets so the validator doesn’t choke.

    But that’s not likely to help you since my client scripts were working BEFORE the CDATA tagset additions. So I doubt that’s it….

    Hmmm. I took your code, took out the extraneous *s so it looks like this:

    <script type="text/javascript"><!--
    flickr_badge_background_color = "#FFFFFF";
    flickr_badge_border = "0px solid #FFFFFF";
    flickr_badge_width = "0px";
    flickr_badge_height = "150px";
    flickr_badge_text_font = "0px Verdana, Arial, Helvetica, Sans serif";
    flickr_badge_image_border = "0px solid #000000";
    flickr_badge_link_color = "#000000";
    //--></script>
    <script type="text/javascript" src="https://www.flickr.com/badge_code.gne?nsid=
    90884061N00&count=2&display=random&name=0&size=
    square">
    </script>

    and loaded it on one of my own blogs at https://vkaryl.net/pov/ – and while of course it’s not showing anything much since the nsid is a fake, it’s not borking, and it IS showing a small white square. I don’t of course know if that means anything….

    Looking a bit more: you’ll need to “unzero” the 0s in that script, too – which will at least display something; for instance, this section should look something like this instead of what you’ve got now:

    flickr_badge_border = "1px solid #FFFFFF";
    flickr_badge_width = "150px";
    flickr_badge_height = "150px";
    flickr_badge_text_font = "10px Verdana, Arial, Helvetica, Sans serif";
    flickr_badge_image_border = "1px solid #000000";

    and if you don’t have your gallery set up right on flickr…. that could be a problem. Did you get the code from flickr or just grab it off Ethan’s site?

    vkaryl, he had js turned off on unapproved sites in his browser, and since he had never used js on his sites before, his browser was blocking it. Turned out his code was fine.

    What I get for editing without checking! Ah well, at least it’s fixed!

    Thread Starter quixote7

    (@quixote7)

    vkaryl, your reply helps with something else: when I checked validation, the funky flickr script generates a river of errors. I’ll look into the CDATA tagset to fix that. Had no idea what to do before!

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘howto put javascript into templates?’ is closed to new replies.