• Resolved MAzCastro

    (@fmacastro)


    Hi

    I’m using the wp_enqueue_script method to add scripts to a theme.

    wp_enqueue_script( 'farbtasticJS', '(..)farbtastic.js');

    when I look at the postProcessed source I can see the scripts correctly included in the head section, but they are completely ignored by the browser.

    If I echo them, they are also correctly included in the head section, but now they are perfectly interpreted by the browser!

    echo("<script type='text/javascript' src='(..)farbtastic.js'></script>");

    weird!

    I want to code this the proper way, and I don’t want to hard-code them by echoing the code.

    Can someone please help me to understand what might be wrong?

    Thanks

    MAC

Viewing 6 replies - 1 through 6 (of 6 total)
  • Did you call <?php wp_head(); ?> *after* wp_enqueue ?

    Thread Starter MAzCastro

    (@fmacastro)

    Hi veganist!

    Did you mean to ask, if I have <?php wp_head(); ?> in my theme?

    yes I do.

    This is a weird case. I’ve done everything “by the book” and it doesn’t work. But if I do it “the wrong way” it works. I’m tempted to…

    This is a function to place a JavaScript color-picker to my theme options (trough function.php), so we′re talking “admin context” not front-end.

    I tried both:

    add_action('admin_print_scripts', 'myColorChoiceScriptz');
    add_action('admin_init','myColorChoiceStyles');

    to hook my functions, but none seem to work properly (I’ve tried both combination for scripts and CSS)

    They DO place the scripts, and the CSS in the markup, but then the browser ignores them!

    The fist thing that comes to my mind is: – they are been processed in a wrong order, that’s why they are being ignored.
    But according the the Codex, “admin_init is triggered before any other hook when a user access the admin area”, so it doesn′t make sense.

    It probably is just a detail I’m missing here.

    HELP!

    MAC

    Thread Starter MAzCastro

    (@fmacastro)

    Hummmm

    Did you call <?php wp_head(); ?> *after* wp_enqueue ?

    You might have a point that I missed, <?php wp_head(); ?> can be too “low” ?? on the markup, thus making head scripts to load after the other “wicked stuff” I’m calling!

    I’ll give it a try and place it at the beginning of the markup!

    MAC

    Thread Starter MAzCastro

    (@fmacastro)

    Silly me!

    I was not thinking. This has nothing to do with <?php wp_head(); ?> since this refers only to the admin section, and not the theme itself.

    But it was a nice try ??

    MAC

    once again: HELP!

    Thread Starter MAzCastro

    (@fmacastro)

    Please grab some heavy stones and aim at my dumb head.

    I was calling a JQuery-dependent-script, BEFORE I called the JQuery script itself.

    Shoot at will, I deserve it.

    MAC ??

    :))

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wp_enqueue_script not working properly’ is closed to new replies.