Quick Fix: WordPress ‘Add Media’ Button Not Working Issue

Quick Fix: WordPress ‘Add Media’ Button Not Working Issue

Sometimes it happens that the Add Media button on your WordPress site suddenly stops working for any reason. And you don’t get cause because this problem does not show you any warning or error. This leaves users clueless about why their button is not working. In this frustrating situation, users don’t have any idea to add images, gif, and videos. keeping this in mind, in this post, we have discussed how to fix WordPress add media button not working issue.

Before starts let’s get an overview on WordPress add media button;

What is ‘Add Media’ button in WordPress?

The ‘add media button‘ in WordPress is available on the post editor screen that allows you to add media items such as images, videos, and GIFs, into your WordPress post. But sometimes it does not work properly so that users get bothered and cannot add media item to their post or pages.

Likewise all WordPress errors, it does not show you any causes, that’s why you have to find out yourself causes of this error. Let’s see the causes of this error.

Causes: Why ‘Add Media’ button stop working?

Often this error is caused by conflicting scripts or style that is loaded by WordPress plugin or theme installed on your WordPress website. However, by default WordPress load all needed script and stylesheets by combining the request. 

Basically, this is done in the WordPress admin area to boost the speed and performance of your site. For all screen buttons including add media button, WordPress post editor uses JavaScript. And you know that a conflict can stop JavaScript from working that become the cause of disabling the ‘Add media’ button.

How to Fix Add Media Button Not Working in WordPress

Over to this, let’s see how to troubleshoot and fix the Add Media button in WordPress.

How to fix WordPress ‘Add Media’ button not working issue

Add the given below code to your wp-config.php file and fix your error quickly. To add this, you have to edit the wp-config.php file and add the code before ending. 

define(‘CONCATENATE_SCRIPTS‘, false );

This mentioned above code allows WordPress to load every script separately, and helps to avoid JavaScript conflict with buggy Script and WordPress core features.

Once you have added the code, thereafter go to the post edit screen and check the add media button is working as expected or not.

Note: Adding this code is a short-term solution because you have the script due to which the error occurs. You can find the source of the problem easily by using the inspect tool. The inspect tool will display you console errors that can access you to the source of conflict.

If you want to fix this problem for the long-term, so you have to apply the basic WordPress troubleshooting tips to check which one – a plugin or theme cause this problem.

We suggest, apply this task on your staging site instead of live site. However, all the good WordPress hosting companies such as SiteGround, WP Engine, Bluehost, and Liquid Web provide one-click staging functionality.

On your offline (staging) site, you have to deactivate all your WordPress plugins and check whether the add media button working, if yes, it means, the plugin is causing the error.

How to Fix Add Media Button Not Working in WordPress 1

Now activate the plugin one-by-one, and check the add media button after activating each plugin. Doing the same will help you to find out which plugin is causing the error. Once you found, you can deactivate or replace it with another one or ask the author of the plugin for help.   

If still, you are also facing the problem by deactivating the plugin, means the plugin is not resolving the problem, then you can switch to a default WordPress theme such as twenty-seventeen.

How to Fix Add Media Button Not Working in WordPress 2

If switching to the default theme fixes the issue for you, then this means your theme is causing the conflict. You can ask the theme author for support or switch to a different WordPress theme.

Once you fixed the problem on your staging site, then apply it on live WordPress site.

That’s all!

If you have multiple user roles such as contributor, author, editor, etc. and you don’t want to allow them to add media to the post. In this situation, you can hide the ‘Add media’ button easily from non-admins. Let’s see how;

Hide “Add Media” Button from Non-Admins

To hide the ‘add media’ button from non-admins, you need to add the given below code to your functions.php file. 

However, if you want that – only editors see the add media button, so you can change ‘manage_options’ to something which Editors have permission to do, like ‘edit pages’.

1 function RemoveAddMediaButtonsForNonAdmins(){
2          if ( !current_user_can( ‘manage_options’ ) ) {
3             remove_action( ‘media_buttons’, ‘media_buttons’ );
4          }
5 }
6 add_action(‘admin_head’, ‘RemoveAddMediaButtonsForNonAdmins’);

Access Own Media Only

We have given below code – the admin can see all media with this code.

As we have discussed above, if you want that, editors see all the media, so you have to change ‘manage_options’ to something which editors have permission to do, like ‘edit pages’.

1 /**
2 * Allow access to own content only
3 */
4 function my_authored_content($query) {
5
6 //get current user info to see if they are allowed to access ANY posts and pages
7 $current_user = wp_get_current_user();
8 // set current user to $is_user
9 $is_user = $current_user->user_login;
10
11 //if is admin or ‘is_user’ does not equal #username
12 if (!current_user_can(‘manage_options’)){
13       //if in the admin panel
14       if($query->is_admin) {
15
16              global $user_ID;
17             $query->set(‘author’, $user_ID);
18
19     }
20     return $query;
21 }
22 return $query;
23 }
24 add_filter(‘pre_get_posts’, ‘my_authored_content’);

That’s all

We hope this article will help you to fix add media button not working issue. In case you have any related to this query, so let me know in the comment section. We are happy to help you.

If you still need help contact  our WordPress Technical Support Team. Please Dial +1-844-275-0975 (Toll-Free). We  have a team of good professional who can resolve all your issues related to WordPress.



Leave a Reply

Call Now