• Hello, I’m having a bit of an issue, I made a calendar in php, the way I have it to work is that I made 3 javascript functions and the php page automatically puts the right calls for said functions on the right place and the calendar works.

    However when I try and do this in wordpress it just seems more complicated then it should be, like javascript needs to be registered in particular ways and so on, I’m really lost this is the function I have for the calendar going forward 1 month

    function forward() {
    $.get("date.php", { month: count } , function(data){
    $("div#Calendar_wrap").html(data);
    });
    count = count + 1;
    back = count - 2;
    }

    what it pretty much does is sends out a call on the php file with a month value and the php file’s output gets placed in the Calendar_wrap div, how would it be possible to do that in wordpress?
    I’ve seen loads of tutorials online but most of them are about different things it’s kinda wierd

    Thanks.

Viewing 1 replies (of 1 total)
  • If it’s a jquery script, then jquery is ‘pre-registered’ and packaged with the WP core. You should simply be able to enqueue it…

    wp_enqueue_script( 'jquery' );

    then enqueue your script adding jquery as a dependency…

    wp_enqueue_script( 'my-script', '/path/to/script', array( 'jquery' ) );

    Check first to see if jquery is loading by default in your theme. If so then just add the second line to your functions.php in a function and fire on init…

    function my_init() {
       if( !is_admin() ):
          wp_enqueue_script( 'my-script', '/path/to/script', array( 'jquery' ) );
       endif;
    }
    add_action( 'init', 'my_init' );
Viewing 1 replies (of 1 total)
  • The topic ‘Calling file with javascript’ is closed to new replies.