Fix: WordPress Add Media Button Not Working Issue

Fix: WordPress Add Media Button Not Working Issue

One of our readers recently reported that the Add Media button on their WordPress site has stopped working suddenly. However, this problem does not display any error or warning which leaves users clueless about why their button is not working. Here In this article, we are going to describe How to Fix Add Media Button Not Working in WordPress.

Add Media Button Stop Working: Cause

However, this problem is commonly caused by conflicting scripts or style loaded by WordPress plugin or theme installed on your website. Add default behavior of WordPress is to load all required scripts and stylesheets by combining the request.

This is commonly done in the WordPress admin area to improve performance and speed.

The WordPress post editor uses JavaScript for all buttons on the screen, which includes the button. A conflict can prevent JavaScript from working which will disable the ‘Add Media’ button.

How to Fix Add Media Button Not Working in WordPress

It is being said, let’s see how to troubleshoot and fix the button that is not working in WordPress.

Fixing WordPress Add Media Button Not Working Issue

The Quick Fix is to add the following code to your wp-config.php file. You can do this by editing the wp-config.php file and you can add this code right before the line which says ‘That’s all, stop editing! Happy blogging’.

define(‘CONCATENATE_SCRIPTS’, false );

This code simply asks WordPress to load every script separately, which helps to avoid javascript collision with the buggy script and core WordPress features.

After adding the code, go ahead and edit the visit post screen to see if the media is working as expected or not.

Note: Adding this code is not a long-term solution because you still have a script that is causing the issue. An easy way to find the source of the problem is to use the inspection tool. This will show you console errors that can lead you to the source of conflict.

If you want a long-term fix for this problem, then you need to perform the basic WordPress troubleshooting tips to figure out which plugin or theme may be causing the problem.

We strongly recommend that you do this on your staging website instead of the live site. All the best WordPress hosting companies like WP Engine, Bluehost, SiteGround, and Liquid Web offer 1-click staging functionality

On your staging site, you have to start by deactivating all your WordPress Plugin and then checking whether it fixes the ‘Add Media’ button or not. If this happens, then it means that one of the plugins was causing the issue.

How to Fix Add Media Button Not Working in WordPress 1

Now you can activate the plugin one-by-one, and after activating a plugin check the button. This will help you to figure out which plugin is causing the problem. After finding the culprit, you can replace it with any other plugin or ask plugin author for help

If deactivate the plugin does not solve the issue, then the next step is to temporarily 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, it means that your theme is struggling. You can ask theme author for support or switch to another WordPress theme.

Once you find the source of the problem on your staging website, you can apply the fix to your live WordPress site.

Hide “Add Media” Button from Non-Admins

Add the following code to your function.php file. It will hide buttons from all non-administrators.

If you want to allow editors to view buttons, you can change ‘manage_options’ to something that editors are allowed to do, like ‘edit page’.

function RemoveAddMediaButtonsForNonAdmins() {

if  ( !current_user_can( ‘manage_options’ ) ) {

remove_action( ‘media_buttons’,’media_buttons’ );

}

}

add_action( ‘admin_head’ , ‘RemoveAddMediaButtonsForNonAdmins’ );

Access Own Media Only

With this code, the administrator can see all the media. If you’d like to let Editor see all the media too, you only have to something that editor is allowed to do, like ‘edit page’.

/**

* Allow access to own content only

*/

function my_authored_content($query) {

//get current user info to see if they are allowed to access ANY posts and pages

$current_user = wp_get_current_user();

// set current user to $is_user

$is_user = $current_user->user_login;

//if is admin or ‘is_user’ does not equal #username

if (!current_user_can(‘manage_options’)){

//if in the admin panel

if($query->is_admin) {

global $user_ID;

$query->set(‘author’,  $user_ID);

}

return $query;

}

return $query;

}

add_filter(‘pre_get_posts’, ‘my_authored_content’);

Conclusion

In this article, we have described to you how to Fix Add Media Button in WordPress and covered major topic. After that, we have discussed some topics:

  • What causes the WordPress  Media Button to Stop Working?
  • Fixing Add Media button Not Working Issue in WordPress
  • Hide “Add Media” Button from Non-Admins

That’s all we hope this article helped you. If you have any query related to this, then 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 888 614 0555 (Toll-Free). We  have a team of good professional who can resolve all your issues related to WordPress.

Recommended Blogs:



Leave a Reply