WordPress.org

Support

Support » Plugins and Hacks » php and javascript in posts

php and javascript in posts

Viewing 8 replies - 1 through 8 (of 8 total)
  • I use Run PHP.

    There is RunPHP and http://www.navidazimi.com/projects/wp-exec will allow you to run PHP. You don’t need anything to run javascripts on a post – except you have to actually order the javascript like this:

    <script type="text/javascript" src="/scripts/top.js">
    <!--
    top()
    //---></script>

    So save the script in a script file and call it, don’t put the script code in the post.

    And I would also reinforce this by running TextControl plugin so you can set the formating to not convert the >< into character codes on a per post basis.

    that code didn’t work on this one

    <script language=”JavaScript” type=”text/javascript”>
    <!–

    var username = “moshu”;
    var hostname = “moshu.com”;
    var linktext = “contact us by email”;
    document.write(“<a href=” + “mail” + “to:” + username +
    “@” + hostname + “>” + linktext + “”)

    //–>

    </script>

    TechGnome

    @techgnome

    Moderator

    ongakukaku – yeah, I couldn’t get that to work either, butI did find that if I use the syntax lorelle posted, it does work….
    Except that I did it like this:

    <script type="text/javascript" src="/scripts/top.js"></script>

    -tg

    For information on running Javascript, see Using Javascript. In order to run PHP inside of posts, something not recommended, you can use RunPHP or PHPExec, both found here:
    http://codex.wordpress.org/Plugins/Posts_Formatting

    that format didn’t work for me, kind of makes sense though that some javascript wouldn’t work in pages, since the page is not a real page, just content spit out from the database

    i finally got this one to show up on the page

    <script language=”JavaScript” type=”text/javascript”>
    <!–

    var username = “moshu”;
    var hostname = “moshu.com”;
    var linktext = “contact us by email”;
    document.write(“<a href=” + “mail” + “to:” + username +
    “@” + hostname + “>” + linktext + “”)

    //–>

    </script>

    the only problem now is, it shows up at the very top of the page moving the wp layout down below it.

    I tried using a div tag but the javascript doesn’t seem to be formatable via the css

    anyone have any ideas how to drop the email down into the page where it belongs ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘php and javascript in posts’ is closed to new replies.