@wordpress/components Button variants not styled

The WordPress components docs are pulled from the development branch of the repository, meaning they may describe features and functionality that have yet to be released. With the current version of the library used in WordPress, you declare the variant with the isPrimary, isSecondary, or isTertiary property: <Button isSecondary onClick={open}> Select image… </Button>

Jquery conflict

At least one issue I can see is that you’re including the jQuery framework at least twice. The first line <?php wp_enqueue_script(“jquery”); ?> Is the preferred method of including jQuery. Your installation of WordPress happens to include jQuery version 1.4.2. This allows good plugin and theme developers to leverage jQuery and not accidentally include it … Read more

Only loads on the contact template page

First a bit of advise (since the solution is based on it) – always “enqueue” your scripts, don’t just add them in the footer. Read this, for example . Now the solution for loading scripts on specific template, since this is what you asked for: function enqueue_themescrits() { if ( is_page_template(‘contact.php’) ) { //the file … Read more

Using wp_localize_script to store the template url into a variable to use in JS

You are not enqueueing your custom JavaScript file. And calling the var (templateUrl) in JS file without the handle. Follow the following: I’m enqueueing my custom JavaScripts file (script.js) under the dependency of jQuery, so it will enqueue jQuery library from core. And I’m using the same handle my-custom-js for both my script and localize_script … Read more