How to execute a simple php script in WP (I don’t think wp_enque_script applies here)

I have a wordpress page where I want to include a budget calculation tool.

This budget calculation tool is of course tied to a php script that executes the fields in the budget calculation tool. This php script lives in the file “view.php”

Read More

My question is: how can I execute this php script in WordPress

Here is the script working in a simple HTML/CSS/Js form:

I am so sure this is a beginner thing, but I just can’t get my head around it! What am I missing here?

Thanks so much!

Best,

Gabriela

Related posts

Leave a Reply

2 comments

  1. The short answer is to add it to whatever page template you would like. The view.php file sounds like the wrong place, but if you want it there, just add that code to whatever section of the page you want.

    If you want to go a better route, I’d turn that bad boy into a shortcode. Shortcodes have a bit of a learning curve, but are extremely useful. The benefit to this being that instead of having to copy/paste the code into a new area each time – you can just call [calculator] or whatever you eventually name the shortcode. If you want to execute the shortcode in a template file simply put something like this: <?php echo do_shortcode('[calculator]'); ?>

  2. I would go about this by creating a custom page template. Then plug in the HTML and apply the scripts to this template by embedding the scripts or using wp-enqueue. Then you need to create a new page in WP and assign it the page template you just created with the calculation tool.