First, make sure that your javascript files are loading correctly. Open Developer Tools while on the page (you can right click and select Inspect).
Under the Elements tab, do a search for your javascript files, to make sure they are being enqueued on the page.
Also check the Console tab for any javascript errors.
Is there a specific reason you’re dequeueing jQuery and enqueuing your own version? WordPress comes with jQuery already included, all you need to do is add it as a dependency to your script file.
Also your registering code needs some things changed:
- You can do everything in the
wp_enqueue_scripts
hook for frontend (admin_enqueue_scripts
is for backend) - When specifying dependencies you should get in the habit of specifying them in an array
- I recommend using a unique slug for your script/style names, as
modal
may be registered by other plugins/themes and could be causing issues (i changed tomymodal
)
function my_custom_enqueue_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array(), '3.1.1', true );
wp_register_script( 'mymodal', get_template_directory_uri() . '/js/jquery.modal.min.js', array( 'jquery' ), '', true );
wp_register_style( 'mymodal', get_template_directory_uri() . '/jquery.modal.min.css' );
if ( is_page( 'kundenprofile' ) ) {
wp_enqueue_script( 'mymodal' );
wp_enqueue_style( 'mymodal' );
}
}
add_action( 'wp_enqueue_scripts', 'my_custom_enqueue_scripts' );
You can also change the priority at when your hook is called, by adding it after the function:
add_action( 'wp_enqueue_scripts', 'my_custom_enqueue_scripts', 1 );
10
is the default when you do not specify one
I also recommend JUST FOR TESTING to remove the check with is_page
to make it enqueue on every page, and if you do, and it works, but when you put that code back it doesn’t … you know the issue is with that function checking the page (although it’s ALWAYS good dev practices to check the page before enqueueing a script .. i wish all devs did this, but they do not)