Solutions When Add Media Button Is Not Working In WordPress
There are primarily four reasons why the Add Media button in WordPress’s admin section might stop working.
- A jQuery or javascript conflict with a recently installed or recently updated plugin or theme
- If you manually added an updated jQuery version to your functions.php
- A cached version is conflicting with the updated version of a javascript
- Browser is caching the page
The Chrome browser’s cache is often the culprit. The first thing to try is to force a hard refresh of the page using CTRL + F5. If that doesn’t work, try a different browser. If the Add Media button works there, you’ll need to clear Chrome’s cache in order to use it again.
Quick fix for javascript conflicts
A quick fix if your browser is not the problem is to add the following code to your wp-config.php file.
define('CONCATENATE_SCRIPTS', false );
If this does work for you, you should only use it until you identify and correct the actual problem.
If you’ve registered a script in your functions.php
If you have manually updated your functions.php with to include a javascript file or newer version of jQuery, be sure to apply the noConflict setting. In the following code, we included a newer version of jQuery
// Add jQuery wp_register_script( 'jquery3.2.1', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js' ); wp_add_inline_script( 'jquery3.2.1', 'var jQuery3_2_1 = $.noConflict(true);' ); wp_enqueue_script( 'plugin-javascript', plugins_url( 'js.js', __FILE__ ), array( 'jquery3.2.1' ) );
Last but not least
If you’ve recently updated a theme or plugin, you’ll have to do a little more work to identify the problem.
- First, make sure your version of WordPress is up to date.
- Switch to a default theme such as Twenty Nineteen. If that resolves the issue, reach out to your theme’s developer for assistance.
- If you have a custom theme, ensure that any javascript dependencies are fully loaded. Use the F12 button to access the Developer’s Console of your browser.
- Disable all your plugins. Enable them each individually, checking your Add Media button each time you enable a plugin. If you identify a plugin that is causing the issue, reach out to the plugin’s developer for assistance.