is_page(79)
is asking if the current main query is a page, specifically page 79
But the main query hasn’t happened yet
This function has to be called inside the main loop or at the very least inside the template, but the init
hook is way too early for this.
Instead, make sure you use the body class, and load the script on all pages. Then, check if the body tag has the css class page-id-79
.
Other Notes
- You don’t enqueue on the
init
hook, you’re meant to enqueue on thewp_enqueue_scripts
hook - It would be simpler to return early e.g.
if ( is_admin() ) return;
- Don’t enqueue jQuery, instead add it as a dependency so WP knows how to output the scripts in the correct order
- main-style and main-vendor are very generic names, you might encounter clashes, prefix them, e.g.
pji-main-vendor
theme_enqueue
is also a very generic function name, you should prefix that too- You can register and enqueue at the same time using
wp_enqueue_script
. If you pass everything to that function there’s no need to callwp_register_script
- Indent your code, modern code editors will do this automatically for free, zero effort. Sublime or Atom are examples of free software that will do this for you, there really are no excuses