Forums

Include javascript file with extension php and using _e (3 posts)

  1. ctomczyk
    Member
    Posted 2 years ago #

    Hi,

    I want to include JavaScript file using:

    <script type="text/javascript" src="file.js.php"></script>

    In this "file.js.php" I want to use _e function, but this doesn't work.
    What do I have to do more to function _e I work in a given file?

    --
    CT

  2. gwozdz.mateusz
    Member
    Posted 2 years ago #

    Hi!

    So, if u want to attach .js file, all U need to do, is use
    <?php include("file.php"); ?>
    In this file start with
    <script type="text/javascript">
    and close the tag after Your javascript.

    Powodzenia ;)

  3. ctomczyk
    Member
    Posted 2 years ago #

    No, I don't ask how to load JavaScript file with php extension. All I had to do is:

    define('ABSPATH', 'abs path to Your wp install');
    require_once(ABSPATH.'wp-config.php');
    require_once(ABSPATH.'url to Your JavaScript file');

    And then You may use _e function.

    Regards,
    CT

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags