简体   繁体   中英

How to put an HTML script file in wordpress?

I've been searching for 6 hours and still haven't found the right answer. I have only little knowledge on coding. So I hope you could help me with this in simple terms...

I have a html file that run a js script. It is a form has something like "if" functions that will show different links depend on the query. I want to put it as a part of my post.

I've tried iframe but the link would show up inside the frame. I've tried target="_blank" but the links are still opening inside the frame. I want to try include but I don't know where I could put this code. And I'm not sure if this code is the right solution for my problem.

<?php echo file_get_contents('http://calculator-bmi.com/wp-content/themes/genesis-flint/js'); ?>

What I only wanted is to put my query form in my homepage. I hope you could help me. Thanks!

Use wp_enqueue_script .

<?php defined('ABSPATH') || exit;
/*
 * Plugin Name: My lovely custom script for javascript
 * Description: Blah, blah, blah...
 * Version: 1.0
 * Author: Jixun
 */

function your_namespace_inc_script () {
    wp_enqueue_script ('your_namespace_inc_script', plugins_url('js/my.script.js', __FILE__), array('jquery'));
}

add_action ('wp_enqueue_scripts', 'your_namespace_inc_script');

Create a folder under wp-plugins , place the php file inside (Any name, I call it index).

Modify the path to the script to your script path (Relative path to the PHP script).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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