functions.php How to add css/js depending on Template Name?

You can use wp_enqueue_style() before running get_header() in your blue.php file. If you’re looking for a way to do that inside your functions.php file, then the init hook is a bit too early for is_page_template(). Try the wp_enqueue_scripts hook instead: add_action( ‘wp_enqueue_scripts’, ‘load_my_theme_files’ ); function load_my_theme_files() { if ( is_page_template( ‘blue.php’ ) ) { wp_enqueue_style( … Read more

async javascript and css for wordpress

You would use the handle of your enqueued scripts, ie, the first parameter of the wp_enqueue_script function used in WordPress for all your scripts… (if you are loading them another way you should use this function instead.) The handle for jQuery is… jquery actually jquery-core now. But each script queued will have it’s own handle. … Read more

wp_register_script(… $in_footer = true) not working

Choose the right place in (rendering-)time First off, you are hooking at init, while you want to add your callback on wp_enqueue_script. Example: add_action( ‘wp_enqueue_script’, function() { wp_deregister_script( ‘jquery’ ); // Rest of logic } ); Staying up to date with core Also, you might want to use the correct version that core uses. I know, … Read more

How to hook into a function offered by a plugin?

Using add_action I am able to add a function to the plugin. // add action to after_record_action add_action(‘after_record_action’, ‘marian_rick_custom_action’, 10, 3); // add function function marian_rick_custom_action ($result, $data, $format){ // get data from $data[] array $email = $data[’email’]; $key = $data[‘key’]; // use $data to create a personalized mail $to = $email; $subject = “Wordpress … Read more

How to hide unused profile fields?

You have the JS part down, in order to have this script run, you can use the add_action function and hook it to the admin_head. This will run your custom JS script in the header of the wp-admin area. Below is the code that you can add to your child theme’s function.php file. I’ve added … Read more