• Hello everyone,
    I have a question that will probably seem simple but I want to make sure I do things right.

    I wanted to create a calculator of sorts for my site.
    I worked in on laptop with a an emulator to test it.

    The products has a css file, a javascript file and an html file for the calls.

    On my local machine all worked well because they were all in the same directory and could see each other.

    If I want to put this calculator on a page in WordPress which folder (I.E. wp-content wp-admin etc.) should I place the css and javascript files so when I place the html on the page it will see them and act accordingly.

    Sorry to bother but I do not want to jack it up.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey,

    You should create a custom plugin for it, or you should add it using a child theme, instead of adding it to theme folders.

    After that, you can add the JS and CSS files to your site using https://developer.wordpress.org/reference/functions/wp_enqueue_script/ and https://developer.wordpress.org/reference/functions/wp_enqueue_style/

    Then you can post the HTML to your page, or create a page template https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

    Hope this will help. 🙂

    Thread Starter nolimit76

    (@nolimit76)

    I will give it a shot and report back. Thanks a lot.

    Hope it works! 🙂

    Thread Starter nolimit76

    (@nolimit76)

    Hardeep,

    So sorry for the delay. I liked the idea of a WP plugin so I tried to go down that road as time permitted but having some issues… I was hoping you might see the flaw…

    I had two variants of my calc. one was the html, css and js files. The other, which I tried to use has the following:

    A main calculator.php file. In that same directory is a subfolder that has the main css and js files.

    I created an includes folder and place the structure above in it. In the same level as the includes folder I made a Horse racing calculator.php file to act as the main file..

    I tried this…

    <?php
    /*
    Plugin Name: HorseRacingCalculator
    Description: A horse wagering calculator to take all the guesswork out of making a bet-amount
    Version: 1.0
    Author: Adam Solowiei
    */

    define( ‘Horse_Calc_Files_Path’, plugin_dir_path( __FILE__ ) );

    include( Horse_Calc_Files_Path . ‘Includes/calculator.php’ );
    ?>

    //My plugin shortcode

    <?
    function HorseCalculator(){
    return ‘calculator.php’;

    }
    add_shortcode(‘HorseCalc’, ‘HorseCalculator’);

    ?>

    But…no joy and the raw calc just takes over the dashboard page. I know I am doing something wrong but missing it. My calculator.pp file is the brain of the item so I want the shortcode to call it and have things run from there.. Is there something obvious I am missing???

    Hi,

    As per forum guidelines, please create a new thread for a new question. And you should include the calculator.php file maybe. It can be done in a lot of ways tho.

    Anyway, a new thread will be more appropriate for that discussion. Hope you understand. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Add A New Project’ is closed to new replies.