• I have an “include” that loads a PHP script that contains some enqueues. I originally put my ‘include’ in the top of my template for the page but I found that the code didn’t get loaded because it looks like “template load” time is too late in the load sequence. I moved the ‘include’ to my functions.php and all works fine BUT I don’t want to load all of this code for all pages—which is what happens with the ‘include’ in functions.php. BUT, I discovered that in functions.php I don’t know what the page is that is being loaded.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there!

    It sounds like this should be possible with conditional tags. Could you tell us on which pages do you want to load your script?

    Thread Starter lwoods

    (@lwoods)

    The problem is that the ‘included’ code includes a routine that is called via Ajax. The code includes:

    add_action( ‘wp_ajax_xxx’, ‘xxx_func’ );
    add_action( ‘wp_ajax_nopriv_xxx’, ‘xxx_func’ );
    function xxx(){ ………….

    It looks like loading this code in the template is too late in the sequence of module loading. When this code is loaded in the template the routine is not executed from javascript—but when loaded in functions.php then it is executed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Code placement for loading in specific page’ is closed to new replies.