Forums

[resolved] use "is_page(x)" to load scripts (2 posts)

  1. dorich
    Member
    Posted 1 year ago #

    I'm trying to load scripts specific to a page using the following:

    function pagePopUps () {
    	if ( is_page(253)) {
    		wp_register_script('popUpVideo1', "http://xxxxxxx/scripts/popUpText1.js", array('jquery', 'jqueryUI'));
    		wp_enqueue_script('popUpVideo1');
    
    	}
    }
    
    add_action('init', 'pagePopUps');

    This does not work.

    Any suggestions on the source of the problem?

    Additional data:
    Static Page
    Child Theme
    Code is located in the functions file of the child theme.

    Thanks.

  2. dorich
    Member
    Posted 1 year ago #

    The problem is with the add action hook.
    To make this work the hook has to be wp.

    See this discussionfor some analysis.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags