WordPress.org

Ready to get started?Download WordPress

Forums

php and javascript in posts (9 posts)

  1. dave_merwin
    Member
    Posted 8 years ago #

    Anyone know of a good plugin for running php in posts and or javascript in posts?

    Lemme know.

  2. yami
    Member
    Posted 8 years ago #

    I use Run PHP.

  3. Lorelle
    Member
    Posted 8 years ago #

    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.

  4. ongakukaku
    Member
    Posted 8 years ago #

    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>

  5. TechGnome
    Moderator
    Posted 8 years ago #

    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

  6. Beel
    Member
    Posted 8 years ago #

  7. Lorelle
    Member
    Posted 8 years ago #

    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

  8. ongakukaku
    Member
    Posted 8 years ago #

    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

  9. ongakukaku
    Member
    Posted 8 years ago #

    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 ?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags