SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    404 error caused by js file called from wrong place in php file

    I don't know a whole lot about this but I think I know where the problem is, I just don't know how to fix it.

    Location of 404: http://examplesite.com/wp-content/th...stom/custom.js

    Turns out the custom.js file in question is now at the child theme: themes/freshcanvas/custom/custom.js
    And the link above is pointing to the theme.

    So here is some code from the themes/freshcanvas/custom/content/footer.php file, and at the bottom you can see this:
    <script src="<?php echo esc_url( get_bloginfo( 'template_url' ) ); ?>/custom/custom.js" type="text/javascript"></script>

    But how do I edit that so it points to the child theme instead of the theme?


    Here is the full bit of php for this container:

    // Add footer container
    add_action( 'woo_footer_before', 'footer_container_start' );
    function footer_container_start() { ?>
    <!--#footer_container_start-->
    <div id="footer-container">
    <?php
    }
    add_action( 'woo_footer_after', 'footer_container_end' );
    function footer_container_end() { ?>
    </div><!--/#footer_container_end-->
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    <script src="<?php echo esc_url( get_bloginfo( 'template_url' ) ); ?>/custom/custom.js" type="text/javascript"></script>
    <?php
    }
    ?>


    Thanks,
    Will

  2. #2
    SitePoint Member
    Join Date
    May 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind I just figured it out...just had to change this:

    <script src="<?php echo esc_url( get_bloginfo( 'template_url' ) ); ?>/custom/custom.js" type="text/javascript"></script>
    to this:
    <script src="<?php echo esc_url( get_stylesheet_directory_uri( 'template_url' ) ); ?>/custom/custom.js" type="text/javascript"></script>

    get_stylesheet_directory_uri loads from the child theme if there is one present...

    some more info in case anyone is interested:
    http://codex.wordpress.org/Function_...e/get_bloginfo
    http://wordpress.stackexchange.com/q...fotemplate-url
    http://justintadlock.com/archives/20...rdpress-themes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •