繁体   English   中英

包含带有几个js文件的php文件

[英]include php file with several js files

我有一个小问题。 我将3个文件上传到服务器。 1个php文件和2个js文件。 PHP文件引用了这2个JS文件。 我需要在Wordpress中的页面上运行此文件。 我尝试安装EXEC PHP插件,然后写了

include './online/demo_iframe.php';
wp_enqueue_script( "jquery.ba-postmessage", "./online/jquery.ba-postmessage.js", false, false ); 
wp_enqueue_script( "jquery.min", "./online/jquery.min.js", false, false );

但这不起作用。 因此,问题是,我知道如何使用“ include”运行php文件,但我不知道如何将此php文件与我的2个js文件连接。 谢谢。

出现URL路径问题,请尝试使用文件的完整(而非相对)路径:

<?php
//For PHP include, use full path to your file, e.g. /var/www/example.com/wp-content/themes/etc/etc
include 'full_path_to_your_php_file/online/demo_iframe.php';
//For JS scripts, use bloginfo('url') to point to your files
wp_enqueue_script( "jquery.ba-postmessage", bloginfo('url')."/path_to_your_theme_file/online/jquery.ba-postmessage.js", false, false ); 
wp_enqueue_script( "jquery.min", bloginfo('url')."/path_to_your_theme_file/online/jquery.min.js", false, false );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM