Search
  • Software by
  • Christoph Amthor
  • Software von
  • Christoph Amthor
Search Menu

How To Fix The WordPress Error “The plugin does not have a valid header”

Photo by transitpeople

I recently came across that error when trying to install and activate a plugin on my self-hosted WordPress sites. The message simply said: “The plugin does not have a valid header” Unfortunately, it was not really helpful to debug the problem. What made it even more mystifying was the fact that the plugin could still be activated from the list of plugins, but not directly after installation.

This problem is often caused by a wrong folder structure in the plugin – for example if the plugin’s main file is placed in a second level under the “wp-content/plugins/” directory:

wp-content/plugins/my-plugin/my-plugin/ (files here)

In that case it helps to move everything up by one level:

wp-content/plugins/my-plugin/ (files here)

That, however, was not the case here. After some searching I found that the headers of some PHP files hidden in the sub-folders of the plugin looked similar to the mandatory header of plugin main files:

/*
Plugin Name: ...
Plugin URI: ...
Author: ...
...

WordPress seemed to assume that one of those files was the actual main plugin file.

I fixed the issue by going through all files and changing the format of the headers to something that wouldn’t confuse the installer. Afterwards, the installation needed to be repeated from the start with the correct files.

Photo by transitpeople

Share
  • 3
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Check Out My Plugins:

Organize your tags in coherent groups and tidy up your tag cloud! Display your tags under tabs or in an accordion.

You will never want to go back to the times when your tags were all over the place.

FREE

Supercharge your tags! Tag your posts on two levels with tag groups. Filter your posts on the frontend. Let your visitors search in real time by tags and groups.

Go directly to your first, latest or a random post just by adding some magic words to your site's URL. Search posts by author, or category, or something else. Or combine a time frame with search parameters.

FREE
Updated: 2018-07-27T07:18:33+00:00

3 Comments Write a comment

  1. Indeed this was actually what happened to my plugin, I had to remove the individual headers from the files. Thank you.

    Reply

  2. Can you offer some insight into exactly how you removed the individual headers from the files. Much appreciated in advance!

    Reply

    • You will need to edit the files where these headers occur with a text editor that lets you edit code without adding any formatting, for example with one of those: https://en.wikipedia.org/wiki/List_of_PHP_editors Just unzip the plugin’s ZIP file, edit the files and zip them again, then install that new ZIP file. It’s a bit tricky if you are not used to edit code, so in that case it might be easier and safer to contact the plugin author.

      You may also try the Plugins -> Editor page in the WordPress back end, select the plugin on the right hand side and then go through all files ending on “.php”, but you risk to make your site inaccessible if you produce an error in the code. See https://codex.wordpress.org/Editing_Files

      What exactly to edit: I don’t remember what I actually did one year ago, but it should be OK to remove inside the comments /* … */ some or all of:
      Plugin Name: …
      Plugin URI: …
      Author: ..
      or to change the key words (“Plugin Name:” becomes “Plugin Name B:” or similar). That’s probably safer, since you don’t risk to break the comments (/* …*/). Just make sure you don’t touch the headers of the main plugin PHP file in the main directory. The main file is usually a file with an identical name as that plugin’s directory with appended “.php”, something like “example-plugin/example-plugin.php”.

      Reply

Leave a Comment

Required fields are marked *.