Support » Fixing WordPress » Fatal error: Uncaught Error: Class ‘WP_Post_Type’ not found in

  • Hello everybody,
    I wanted to move WordPress from a subfolder to the Root Directory, so (according to the instructions I found on a website) I made a back up and then I removed the site files from the builder and also the database.
    I went to the admin dashboard and I changed the Word Press address.
    Then I modified index php.
    As those operations weren’t succesfull I decided to delate all and to restore my backup.( database backup also).
    But now I can’t access to the admin dashboard neither to the website.
    And I’ m getting : Fatal error: Uncaught Error: Class ‘WP_Post_Type’ not found in /web/htdocs/ Stack trace: #0 /web/htdocs/ register_post_type(‘post’, Array) #1 /web/htdocs/ create_initial_post_types() #2 /web/htdocs/ require_once(‘/web/htdocs/www…’) #3 /web/htdocs/ require_once(‘/web/htdocs/www…’) #4 /web/htdocs/ require_once(‘/web/htdocs/www…’) #5 /web/htdocs/ require_once(‘/web/htdocs/www…’) #6 {main} thrown in /web/htdocs/ on line 1252

    Appreciate any help you can give me!!

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator t-p


    If your intent was to keep the wordpress in the pre-existing sub-directory (, but make it accessible/serve it from root (, review this reference material:

    Using a pre-existing subdirectory install (take a look at step 4)

    Thread Starter kriss8416


    Thank you T-P
    I created a .htaccess file in root folder but I’m still getting the same error… ๐Ÿ™

    Are you trying to take a WP installation which is in a subdirectory, such as and move it to the root,

    You said you did it “(according to the instructions I found on a website)” Where did you find these instructions? Give me the full URL to them, I’d like to look at what they tell you to do – for future reference, when you refer to something you found on a website, give us the full URL so we can see what you saw.

    You say you did a backup – how did you make a backup? There are multiple methods out there and saying you made a backup doesn’t provide enough information to allow us to know exactly what you are talking about.

    In software you have to be letter perfect and when asking for help you must tell us everything about what you did and how you did it. I tell people that I’m not physic and can’t read their mind.

    Does your site in the subdirectory still work or is it, and the root copy, screwed?

    If the subdirectory copy still works, I suggest you install the Duplicator plugin and use it to create copy of the site which you can fairly easily install wherever you want, like in the root.

    You are leaving out enough details to make this hard for me to help you.

    Always tell more than you think necessary, rather than less.

    You said:

    I removed the site files from the builder and also the database. I went to the admin dashboard and I changed the Word Press address. Then I modified index php.

    What exactly did you do?

    How did you move (I hope wasn’t a move not copy) the WP subdirectory contents to the root directory?

    What do you mean when saying your removed the site files and database from the “builder” – what “builder”? What files did you remove? How, exactly, did you remove them?

    Where in the admin dashboard did you change the WP address and what do you mean by “Word Press address”?

    Yous said you updated index.php – I’m assuming you modified the index.php file in the theme’s directory, not one of the index.php files in the WP core directories.

    What did you change in the index.php file and why was it necessary to change the index.php file at all?

    You said “As those operations werenโ€™t succesfull[sic] I decided to delate[sic] all and to restore my backup.( database backup also).”

    What did you delete – everything you had put in the root?

    What it comes down to is – does the original site in the subdirectory still work, can you get to the admin pages in order to download, activate, and use Duplicator?

    If the original installation in the subdirectory still works download, install, and activate the Duplicator plugin. Use it to make what it calls a Package and an Install.php file.

    You then copy the package and install.php to where you want to put the WP installation, give it some information such where it is to reside, the database name and password, and it will install the copy and you should be able to then log in to the site as you did before.

    If your original site, in the subdirectory, does not work, I’m not sure what to suggest.

    The Duplicator plugin has a bit of a learning curve but once you’ve used it you’ll understand it.

    It creates a zipped file containing everything from the site – the database and everything else that isn’t in the database – images, etc.

    But, again how did you create your backup and can you restore it to get the subdirectory site working again?

    Another tip – when you want to include a multiline PHP error message, use the browser’s display source feature to get to the source. Then select and copy the error messages.

    Then go to the message you want to show it in and paste what you copied. Then select what you pasted and click the code button in the formatting bar at the top of the message you are writting. It will be so much easier to read the error messages if you do it this way.

    Here’s your error messages added as I just described.

    Fatal error: Uncaught Error: Class 'WP_Post_Type' not found in /web/htdocs/ Stack trace: #0 /web/htdocs/ register_post_type('post', Array) #1 /web/htdocs/ create_initial_post_types() #2 /web/htdocs/ require_once('/web/htdocs/www...') #3 /web/htdocs/ require_once('/web/htdocs/www...') #4 /web/htdocs/ require_once('/web/htdocs/www...') #5 /web/htdocs/ require_once('/web/htdocs/www...') #6 {main} thrown in /web/htdocs/ on line 1252

    I posted this and then saw that the “code” option does not function as it does on other forums – so ignore what I said about making the error messages easier to read.

    As to your problem, give me the information I’ve asked for above and I’ll see if I can get you past this problem.

    • This reply was modified 3 years, 6 months ago by tferral.
    Thread Starter kriss8416


    Hi Tferral,
    thank a lot for your help.
    Yes, I was trying to move the wp installation to the root.
    The website where I found the instructions is this:
    I did the backup following the instructions of this website:
    Those are in Italian but I hope they could easily be translated with google translator.
    The site in the subdirectory doesn’t work, it is screwed. I can’t even get to the admin pages.
    When I say that I removed the site file from the builder I mean that I went to FileZilla, clicked on the root ( to open it, selected all the directories (.htaccess, softaculous and cgi-bin) except the wp one and deleted them.
    Then I went to WP admin dashboard, general settings, web site URL and I changed the URL: from “ ” to “”
    After I returned to FileZilla, I cut and pasted index.php from the subdirectory WP-Admin to the root, I modified it in this way:
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . ‘/wordpress/wp-blog-header.php’ );
    As those operations weren’t successful I went to Filezilla, select the root ( and deleted it.
    Then I opened the BackUp Directory, I selected all the directories and uploaded them to the Server.
    I hope I have been more clear this time but if it’s not, ask me for more information and I will try to answer you. Thank you again for helping me!

    Tip – when writing a message, press Enter twice, not just once, to insert blank lines between thoughts or paragraphs. White space (blank lines and spaces) make things much easier to read. Some forums will submit the message when you press Enter but not the forums here on WP.
    I’m adding this after I submitted the reply –

    You said you created a .htaccess in the root. You will probably have to delete it before attempting the steps I give you, below. But, instead of deleting it, rename it to something like old.htaccess.
    *************** END EDIT

    I as able to use Google Translate to look at the page where you go the instructions.

    Which method did you try to “move” WP to the root” – that page give you two ways?

    Transfer (without moving) WordPress from a sub-folder to the main folder


    Move WordPress from a subfolder to the root folder (physically)

    I’m guessing you used the first method because of your description of what you did.

    Unfortunately, without experience with FTP and MYAdmin, the steps they give you are fraught with danger. If you don’t understand each step, you can find yourself in trouble, as you are right now.

    They tell you how to do the steps but they don’t fully explain what you are doing and, more importantly, why you are doing it. That leads to problems.

    You said:

    When I say that I removed the site file from the builder I mean that I went to FileZilla, clicked on the root ( to open it, selected all the directories (.htaccess, softaculous and cgi-bin) except the wp one and deleted them.

    I see the instructions saying:

    ## Delete all files and folders

    Delete all WordPress files and folders in the main folder including the database, paying attention only to not delete the sub-folder where you are developing the new website (in this example the wordpress folder).

    Perhaps the translation is bad but what I’m seeing talks about deleting an “old” WP installation, if there is one, in the “main” folder (let’s stick to calling the “main” folder, the root folder or root directory or just the root.

    Those instructions don’t say to delete everything in the root, they say to delete ANY old WP installation in the root.

    Did you have a WP installation in the root directory when you began this entire procedure? I’m guessing that you didn’t.

    You deleted everything in the root directory except the subdirectory where WP was installed – correct?

    That really screwed things up.

    Do you have a backup of what was in the root directory, besides the subdiretory where WP was installed?

    If not, can you remember some of the files and directories?
    Okay, let’s do this:

    You will be making a backup of everything on the server, downloading latest version of WP, install it in the root directory and give it the name and password of the existing database. That should put you back in operation and then you can change settings, install any plugins, and get the site working and looking like it originally did in the subdirectory.

    1) Use Filezilla to copy everything in the server root to a new directory on your computer – say c:\wpbackup Download everthing in the root to the new directory – all files and directories.

    2) Delete any WP files in the root directory. Don’t delete the subdirectory where WP was installed and working. Just delete any WP files in the root – I think you have a copy of index.php in the root – if so, delete it.

    3) Go to the directory you just created and copied the root to and open the wp-config.php file with something like Notepad so you can see the database settings. Write down the values for these constants:

    // ** MySQL settings – You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘dbname’

    /** MySQL database username */
    define(‘DB_USER’, ‘dbuser’

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘dbpassword’);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘dbhost’);

    In the example above, the values you would copy are: dbname, dbuser, dbpassword, and dbhost. Write down the values for that information that is in the wp-config.php file in the directory of the backup – the backup copy of the subdirectory where you had WP running before starting this entire affair.

    4) Download and install the latest version of WP from

    Short version of install: download the zip file to your computer. Unzip it. Copy everything in the wordpress directory to the server’s root. Just the contents of the wordpress directory, not the directory itself.

    Go to the root of your site in your browser, such as The installer should being. When you are asked for the database information, input what you wrote down from the wp-config.php file in step 3.

    That should have you up and running with a fresh install of WP in the root.

    You’ll have to change any setting you made in the copy of WP in the subdirectory and install any plugins but you should have a WP copy that runs from the root which can access your database as it was when this all started.

    If you are unsure about how to do any of the steps, ask me about it first.

    I have done a lot of teaching on various computing subjects and, regards of the subject, I will write “Know what you don’t know” on the black/white board, or overhead projected or whatever. I then wait for someone to say something like:

    “How can you know what you don’t know? Once you know it you know it and if you don’t know it you don’t know it.”

    I then write “Know where you knowledge ends” underneath.

    I then explain that when doing anything, you just be constantly asking yourself “Do I know enough to continue?”

    If the answer is no, you go read documentation or ask someone before continuing.

    Blindly forging ahead in an area you have insufficient knownledged leads to problems, sometimes very big one.

    Always be aware of how much you know about the subject at hand.

    Let me know if the steps I’ve given you get you a working WP installation in the root directory on the server.

    • This reply was modified 3 years, 6 months ago by tferral.
    • This reply was modified 3 years, 6 months ago by tferral.
    • This reply was modified 3 years, 6 months ago by tferral. Reason: Correcting a quote
    • This reply was modified 3 years, 6 months ago by tferral. Reason: Adding text at top about the .htaccess file
    Thread Starter kriss8416


    Hi Tferral,
    your explanations were really clear and actually, you guessed every step I took!

    I stuck to your instructions and now I have an installation of WP that works.

    As you were suggesting that it’s always better to ask, so here the question is:
    What I have to do to transfer all the previous contents into this new installation?
    Should I do it by using Filezilla?
    Thank you again for your help!

    • This reply was modified 3 years, 6 months ago by kriss8416.

    I’ve never had a problem that prevented me getting the admin pages to do backups and updates and such.

    You do have FTP access to the server – right? That is how you were able to following my earlier instructions – right? I’m going to assume you have FTP access.

    Before we go any further, I think we should put the site in the root into Maintenance Mode so that no one can do anything that might change the database – right now, it is being shared by the two installations and I want to lock out changes while you do the what I detail below.

    You’d think that WP would provide an Admin feature to do this but, guess what – they don’t.

    I found a simple plugin that will put a site in maintenance mode. I’ve tested it and find no problems with it. To install it:

    1) Login to your new site (on the root) as an administrator.

    2) Go to the Admin page and click on Plugins.

    3) Click Add New

    4) In the search box, on the right hand side about halfway down the screen, enter:

    maintenance mode

    You should see “WP Maintenance Mode” as the second found plugin. The description is:

    Adds a splash page to your site that lets visitors know your site is down for maintenance. It’s perfect for a coming soon page.

    Click “Install Now” for that plugin.

    5) When the installation is complete, click Plugins again in the left hand sidebar of the admin page.

    6) Scroll down as needed to find the Plugin you just installed and click settings.

    The top setting “Status” turns maintenance mode on or off – Activated puts the site in maintenance mode, Deactivated returns the site to normal functioning. That’s the only setting you need to use.

    However, if you want to change the default screen shown when in maintenance mode, click the Design tab and you can alter the message.

    I suggest you simply set Status to Activated to put the site in maintenance mode.

    I know – if I had written it, would say: Maintance Mode and Normal Mode, not Activared and Deactivated.

    When I first saw those choices, I was confused for a split second – then I realized that the status for the plugin, not the site.

    I would have written “Maintance Mode” instead of “Activated” and “Normal Mode” instead of “Deactivated.”

    MY “Status” would refer to the site, not the plugin – just another example of someone not taking a moment to consider how someone unfavorably with the plugin would interpret “Activated” and “Deactivated.”

    The person who wrote it knew what that meant but I’m guessing the majority of people are confused by it, perhaps just for a second, but they would not be thinking in terms of activating or deactivating the unplugin but instead Activating or Deactivating Maintenance Mode.

    I’ll stop before turns into a full blown rant about the state of software production, the people who really don’t know what they are doing, and how WP has all the problems I hate – no comments in code, poor documentation, unruely ways of doing things —– I’ve been in Data Processing for 45+ years and find the current crop of software and programmers lacking far too much knowledge of best methods for producing software.

    ——— Sorry, I said I’d stop before I starts ranting and then I started ranting.

    Once you have the plugin installed and activated, go test it – logout and then go to the site’s URL.

    To login to get back to the Admin page, go to

    Replace with your site’s root URL.

    Okay, let’s get to it as regards seeing if we can recover your other site so you can get at everything you have added to the site.

    QUESTION – on the messed up site, did you make any changes to WP Core files – any files that are not in the wp-content directory or directories of it.?

    If you did, you will lose those changes if we reinstall WP to try to get at the old site – but we have two backups of the entire installation in the subdirectory – right? ๐Ÿ™‚

    I looked around and found instructions on how to manually update a WP installation without losing your custom content. Basically, you copy everything from the unzipped WP installation file that you downloaded and unzipped earlier. BUT YOU DON’T COPY THE WP-CONTENT directory – everything but that directory.

    Go a head and do this, without replacing the wp-content directory which should contain all your custom “stuff.”

    Okay, let’s get started:

    1) Use your hosting companies “panel” to go to PHPMyAdmin and export the database so if it is screwed up in this procedure, you can import. I know you already did that earlier but let’s export again, into a different directory on your computer.

    Note – As you make new directories on your computer, use names that tell you what is in it, don’t try to remember what’s in it, use good names that say what is in the directory.

    Yes, I know you have a Export file for the database from before but, since I like the “belt AND suspenders” method – if the belt breaks the suspenders hold you “pants” up and if the suspenders break, the belt does the job – let’s export it again.

    For the database, the export you did before will be the “belt” and the export you do here will be the “suspenders.”

    What I mean is I always try to have two ways to restore things to where they where when I started making changes to a system.

    2) backup the old site in the directory, using FTP.

    Did you perform this backup step of my earlier instructions?

    1) Use Filezilla to copy everything in the server root to a new directory on your computer โ€“ say c:\wpbackup Download everything in the root to the new directory โ€“ all files and directories.

    If so, that means you have a copy of the entire server site, including the subdirectory with the messed up copy in a directory on your computer – right?

    If so, we can use that directory to put things back to the way they were – in the subdirectory, if my new instructions go wrong.

    But, since we want both a “belt AND suspenders” we will make another copy of the messed up subdirectory on your computer. The first backup of the entire root on the server and everything in it, is the “belt.”

    This new backup of just the subdirectory will be the “suspenders.”

    Start your FTP program and copy everything in the subdirectory, just the subdirectory, with the messed up version to another new directory on your computer. Double check that everything was copied successfully.

    3) When the copy is completed , use FTP go to the directory, on your computer, where you unzipped WP earlier, and to the subdirectory on the server.

    Your FTP program should now be pointing at the unzipped WP directory and the subdirectory on the server with the messed up copy of WP.

    Inside the unzipped package, there is a WordPress directory which contains everything.

    You want to be actually in that directory so that you see directories like wp-content, wp-admin, etc.

    So, once you have the FTP program pointed at the unzipped WP installation files and to the subdirectory on the server, highlight all files and directories except wp-
    content and upload them to the subdirectory with the messed up version.

    You should get messages about files already existing on the server. Filezilla lets you overwrite duplication and there is an option to ignore all further warnings.

    UPLOAD EVERYTHING BUT the wp-content!

    Be sure you are uploading everything from the zipped file to the subdirectory where the messed up copy of WP resides -except for the wp-content directory.

    Once that is done, go to the subdirectory, using your browser, and tell me what happens. Don’t do anything, just go to the messed up site and tell me what happens.

    I continue will the instruction after you get there.

    Here is a condensed version of the steps to perform:

    1) Export the database to a new directory on your computer.

    2) Upload everything from the unzipped copy WP copy,EXCEPT THE WP-CONTENT subdirectory, to the subdirectory on the server where the messed copy resides.

    After all of the above, go to the WP installation in the subdirectory and tell me what happens.


    Go ahead and install that plugin and put the site in maintenance mode, but make no changes to any thing in the root itself via FTP or otherwise. We are only working with the copy of WP in the subdirectory – the messed up copy.

    I’ve got some yard work to do so I will not be checking for a reply from you before, say, 7:00 PM CST.

    P.S. what is the name of the subdirectory containing the messed up copy of WP? I’d like to use the specific name in further comments as a way to make sure we are looking at the same thing.

    Thread Starter kriss8416


    You are my hero! ๐Ÿ™‚
    It did work!!

    I can now access both admin and home page!
    And there are all my contents!!!
    Thank you so much :-)!!

    The name of the subdirectory containing the messed up copy of WP is “WP”
    I wait for new instructions.

    Do you want to move the now working site in the WP subdirectory to the root?

    Let me know and I’ll give the detailed instructions. The short form, very short, is:

    1) Install the Duplicator plugin on the site in the WP.

    2) Create a Duplicator Package

    3) Download Duplicator Package

    4) Test the package – on the server, create a subdirectory of the root named wptesting.

    5) Upload to this new directory, the files downloaded in step 3 to the new wptesting subdirectory of the root on the server. That subdirectory must be empty before you upload the files and it should be if you created it.

    6) Run the Duplicator installer.php – go to with your browser.

    7) Follow the instructions to install the Duplicator package – the instructions are a tad “technical” and I’d need to give you the details to complete the install.

    8) Test the site –

    If you try it on your own, be very careful to following the instructions on each page exactly.

    Let me know if you want to move from WP to the root.

    Thread Starter kriss8416


    Yep, I want to move the site from WP subdirectory to the root.
    That’s where it all started :-D!

    If you don’t mind give me the detailed instructions it would be the ideal otherwise I could stick to the points you wrote, it’s not a problem! Anyway thanks you a lot!

    Thread Starter kriss8416


    Hi Tferral,
    I was going to move the site and I noticed that: the home page is as it was before all that occurred, but if you click on “reading more” in the post, or on images they aren’t any more!

    Instead appears the page “Oops! That page canโ€™t be found” and you are on the new Wp installation…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Fatal error: Uncaught Error: Class ‘WP_Post_Type’ not found in’ is closed to new replies.