Fatal error: Call to undefined function wp_enqueue_media()

As goto10 mentioned in comment, you must be using WordPress 3.5.0 or newer (when this function was added), AND your theme is calling wp_enqueue_media incorrectly. WordPress codex for wp_enqueue_media specifically states : “This function should be called from the ‘admin_enqueue_scripts’ action hook, or later.” Your theme is calling it incorrectly in admin_print_styles which is executed … Read more

How to register script with null value for version?

You literally specify the version number as null: function add_ajax_script() { wp_register_script( ‘ajax-implementation’, get_stylesheet_directory() . ‘/scripts/ajax-implementation.js’, array(‘jquery’), null, false); wp_enqueue_script(‘ajax-implementation’); } add_action( ‘wp_enqueue_scripts’, ‘add_ajax_script’ ); An empty string, ” is not the same thing as null.

I want to set global directory locations for my CSS and JS locations. How?

Sure you can do that. Create a simple plugin that looks something like this: <?php /* Plugin Name: SiteWide Assets Location Plugin URI: www.mysite.com Description: Global URI for commonly used CSS and JS files Version: 1.0 Author: Me License: None */ define( ‘SYSTEM_ASSETS’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/somedirectory/’ ); Then, store your .css and .js files there … Read more

How to load jQuery in TOP of wp_footer?

To properly enqueue jQuery, it’s usually done with wp_enqueue_scripts, there’s no need to load it from cdn as jQuery library are provides in the wp-includes folder of WordPress. Only wp_enqueue_script(‘jquery’); is required. add_action(‘wp_enqueue_scripts’, ‘replace_jquery’); If you really want to replace jQuery with the cdn link, it’s better to register and enqueue it with this function.

load a different stylesheet in a category post

You can do it like- function wpse_enqueue_post_template_styles() { if ( is_category(‘bedrijven’) ) { wp_enqueue_style( ‘post-template’, get_stylesheet_directory_uri() . ‘/layout-interieur.css’ ); } } add_action( ‘wp_enqueue_scripts’, ‘wpse_enqueue_post_template_styles’ ); Here bedrijven is your category slug. As you said the above method hasn’t worked for you, so here I’m suggesting another method- First remove the first method’s full code. Then … Read more

load jquery in footer not working

As Mark Kaplun said in the comments, something is adding defer to your one domain’s script. If you want your subdomain jQuery script to also have defer, this should do it: function my_add_defer ($tag, $handle, $src) { if ($handle == ‘jquery’) { return str_replace (‘ src=”https://wordpress.stackexchange.com/questions/251298/,” defer=”defer” src=”, $tag); } return $tag; } add_filter (“script_loader_tag”https://wordpress.stackexchange.com/questions/251298/,”my_add_defer’, … Read more

Enqueue script only when side widget is used

is_widget_active is what you want e.g. function sidedish_slide_script() { wp_register_script(‘add-sd-js’, get_template_directory_uri() . ‘/form-slider/jquery-1.8.2.min.js’, array(‘jquery’),’null’, true ); wp_register_script(‘add-sd-custom’, get_template_directory_uri() . ‘/form-slider/formslider.js’, array(‘jquery’),’null’, true ); wp_register_style(‘add-sd-css’,get_stylesheet_directory_uri() . ‘/form-slider/styles.css’, ”,”,’screen’ ); if ( is_active_widget( false, ‘widget_id’, $this->id_base, true ) ) { wp_enqueue_script (‘add-sd-js’); wp_enqueue_script (‘add-sd-custom’); wp_enqueue_style (‘add-sd-css’); } } add_action(‘wp_enqueue_scripts’,’sidedish_slide_script’); https://codex.wordpress.org/Function_Reference/is_active_widget

Can’t delete the default jQuery in the theme

An example on how to deregister a WordPress built-in library and load your own: function load_custom_scripts() { wp_deregister_script( ‘jquery’ ); wp_register_script(‘jquery’, ‘//code.jquery.com/jquery-2.2.4.min.js’, array(), ‘2.2.4’, true); // true will place script in the footer wp_enqueue_script( ‘jquery’ ); } if(!is_admin()) { add_action(‘wp_enqueue_scripts’, ‘load_custom_scripts’, 99); }