• Resolved ciantic

    (@ciantic)


    Hi!

    I found myself using this:

    <script type="text/javascript" src="<?php echo substr(locate_template(array('js/3col-shelf.js')), strlen(ABSPATH));?>"></script>

    For overridable javascript/css files. Is there more native way to do this?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ciantic

    (@ciantic)

    In fact the actual code I ended up using is this:

    <script type="text/javascript" src="<?=home_url()?>/<?=substr(locate_template(array('js/3col-shelf.js')), strlen(ABSPATH));?>"></script>

    Still looking for native way to do this!

    Thread Starter ciantic

    (@ciantic)

    That was before I had found out the amazing API functions: wp_register_script, wp_enqueue_script, wp_localize_script

    If you ever consider something I did at first, then you are doing it wrong, check those functions first.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘using locate_template for javascript/css’ is closed to new replies.