Support » Themes and Templates » child theme

  • I am trying to run jquery script in a child theme on a different subdirectory.

    child function has following snipit
    //************ begining
    if ( !is_admin() );
    function my_init_credit() {
    wp_enqueue_script( ‘custom_script’,get_bloginfo(‘get_stylesheet_directory_uri’).’/js/hide_pay.js’,
    //wp_enqueue_script( ‘custom_script’, ‘wp-content/themes/freelancer-child-1/js/hide_pay.js’,
    //This action ensures the my_init() function is called when a page loads.
    add_action(‘init’, ‘my_init_credit’);
    Hook in php page <?php wp_enqueue_script(“jquery”); ?>

    the page is in a subdirectory of the parent called lib/myaccount/xxxx.php so I have added that page to the child theme under the same sub directory structure and am referencing the .js files testing both directly and with get_bloginfo above. The .js directory and file is also in the child theme file

    I have other hooks and jquery running fine but they are running in the header.php and are working fine

    I cannot seem to get the js file to load in the file that is in the subdirectory of my parent theme either by placing it in the child directly or setting it up in the child with the same directory structure as in the parent.

    I have checked firebug and the .js is not executing on that page.

    the jquery code hides an element when the file is loaded.

    I have run the jquery in firebug directly and it hides the element fine
    //**********js code below*********
    var par = jQuery(‘.post_bid_btn’);

    Can anyone give me any in site into how to handle a php page other than the standard index or header or footer in the child theme to run a function from the child function.php


Viewing 2 replies - 1 through 2 (of 2 total)
  • I think you should take a closer look at 2nd parameter of wp_enqueue_script()

    See examples in the doc and compare to yours.

    Thanks paulwpxp
    For the 1000 foot view was the
    wp_enqueue_script( ‘custom_script’,get_bloginfo

    ‘custom_script’ should have been hide_pay

    Now that it works has lead to another problem of coarse.

    I only need this to fire on one certain page I am using
    if (is_page(16));
    but it is initilising and being fired on other pages with the same class identifier
    any ideas up there in the 1000 foot view

    I am using
    add_action(‘init’, ‘my_init_credit’);
    to initialize the hook

    any suggestions on another tag that could be used to initialize for a specific action like page load ?


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘child theme’ is closed to new replies.