Please note, this is not a theme or so issue.
The categories are not showing in the admin panel, however it denotes that there are 6 categories. They are also visible in the database.
Recently something happened with the hosting and any php move_upload
functions started giving errors about missing tmp path, so I created a local php.ini
file to point to the right tm开发者_开发知识库p
folder (home/user/tmp
) and that solved the issue.
This however seems to be linked. I tried setting these in wp-config
define('WP_TEMP_DIR', '/tmp');
define('DBCR_CACHE_DIR', '/tmp');
but to no avail.
I know this is a very dated post but I am putting this here to be discovered by others as there are many threads across the net without a solution discovered. I had the same issue and did a very deep dive on what is happening. The problem is actually with WordPress core and I have submitted a bug ticket for it here https://core.trac.wordpress.org/ticket/33148. I would recommend adding details to it that I may have missed here.
Defining the problem:
The categories are not showing in the admin panel, however it denotes that there are 6 categories. They are also visible in the database.
What is happening is WordPress is looking for categories that have no parent id OR are linked to a parent that exists. If the parent id is set to a non-existent id (other than 0 which means no parent) then the categories will not show up in the list. I will attach several screenshots to show what I mean at the database level before and after.
Query run:
//I am on a multisite instance so this is an example of the query using table numbers.
//If you are on a standard install then wp_terms and wp_term_taxonomy is what you would use.
SELECT * FROM wp_2_terms terms JOIN wp_2_term_taxonomy tax ON terms.term_id=tax.term_id
WHERE tax.taxonomy='category';
As you can see the parent is energy but for some reason the id is not correct. Therefore the children are not linked correctly. I can only assume one of our users removed the parent and then manually added it back but forgot to link the children.
Since I accidentally cutoff the table column names here they are just above.
After you relink the category you should see this in the database
Steps to fix the categorie(s):
- You can use the search feature just above the category list to search for the category if you know its name. Edit the category and either re-choose no-parent OR select the parent that it should be linked to and click save. The category should now show back up in the category list as the parent id is set to a proper value that exists.
- The other option is to update the id in the database to 0 for a parent or the parents id if the category is a child.
I chose option 1 since there may be hooks that are fired on save within plugins or your own custom code. I would think there is less chance of any ill side-effects.
Now the category is there again:
Similar to what @Shawn mentioned in his reply, I had a similar issue but the ID looked correct; no parent issue at all!
What I did was to search for one "invisible category" in the category search field, click on Edit, and then Save (without the need to modify anything).
Then all the sub categories reappeared.
精彩评论