Multiple issues, fixing one or more of which should resolve the issue:
- If it’s not already, that code should go in
functions.php
and not a template file. - Registering the scripts does not actually load them. For that you need
wp_enqueue_script
. If you change yourwp_register_script
s towp_enqueue_script
s, that should work. - If you need jquery, you should enqueue that too.
- You want to wrap the calls to
wp_enqueue_script
in the conditional rather thanadd_action
. For instance, you might want to enqueue a different script on a different page and could do so within the same function.
Put those all together and you should have this in functions.php
:
<?php
function my_enqueue_scripts() {
if (is_page_template('page_blankett.php')){
wp_enqueue_script('jquery');
wp_enqueue_script('ajax', plugins_url('ajax.js', __FILE__), array('jquery'), 'false', 'true' );
wp_enqueue_script('ajax2', plugins_url('ajax2.js', __FILE__), array('jquery'), 'false', 'true' );
}
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );
?>