Invalid post type - wordpress - wordpress

I have a big problem and i dont know how to solve it. I have noticed that at dashboard when i pressed on "all posts" i get this ugly error:
"Invalid post type"
nothing more nothing less
I have tried a lot of things:
1. Update to latest version
2. Roll back to 3.9.1
3. Deactivated/activated all plugins
4. Deactivated custome theme
5. Modify edit.php locate in wp-admin folder and set this
$typenow = 'post';
if ( ! $typenow )
wp_die( __( 'Invalid post type' ) );
After this modification the "invalid post type" error was gone but when I was trying to modify a post at dashboard I noticed that the right column (category select, preview etc) was missing.
Does anyone knows how to fix this problem? Any ideas?
Thank you in advance,
P.S:
Please follow those links to see what I am trying to explain
https://dl.dropboxusercontent.com/u/5502709/wp.png
https://dl.dropboxusercontent.com/u/5502709/wp1.png

Late to the party, but I share this in case anyone comes looking with a similar problem to solve. It isn't a 'fix' but seems to be a 'workaround'.
I'm getting the "Invalid post type" error when I try to edit multiple custom posts in the edit screen. I think I may know a plugin that is causing it, but it's so integral to my site I can't just disable it, even just while I do the editing, so I was faced with the choice of either doing a LOT of individual edits, or coming up with a solution. This is what is working for me:
Set up all of the editing you want as normal. On 'enter' you get the "Invalid post type" message ... but the command phrase is still in the browser bar. Part of the phrase contains'post_type='. For me, at least, rather than the post type I'm trying to edit, it's showing the word 'Array'. By over typing that word with the actual custom post type name, then hitting 'enter' again it processes correctly. (I'm getting a message, but it's a notification or warning rather than an actual error message.)
Hope this helps someone. :-)

Same issue here as described by Kevin4fm:
When I select multiple items for moving to trash and after I hit the button, I can see the following URL in the adress bar of my browser together with the message "invalid post type":
http://example.com/wp-admin/edit.php?s=&post_status=all&post_type=Array&author=5&_wpnonce=67fdf1328g&_wp_http_referer=%2Fwp-admin%2Fedit.php%3Fpost_type%3DCPT%26author%3D5&action=trash&m=0&cat=0&paged=1&post%5B%5D=9462&post%5B%5D=7093&action2=-1
So I have changed the URL to the following and it works fine:
http://example.com/wp-admin/edit.php?s=&post_status=all&post_type=CPT&author=5&_wpnonce=67fdf1328g&_wp_http_referer=%2Fwp-admin%2Fedit.php%3Fpost_type%3DCPT%26author%3D5&action=trash&m=0&cat=0&paged=1&post%5B%5D=9462&post%5B%5D=7093&action2=-1
So changing post_type=Array to post_type=CPT (CPT = name of custom post type) in the adress bar of the browser does the job.
But I can't find any bugs nor in my CPT neither in my theme functions.php, so the reason must be somewhere else...

First of all thank you for helping me. I solved this problem but I dont understand what the problem was. First I removed all the folders of wordpress installation and upload an old backup of my website but the problem was still there. Then I start deleting one by one all the plugins and after each deletion I was checking the behaviour, finally when I deleted this plugin WP Super Cache (which by the way was deactivated) everything worked perfect. The strange think is that when I restore all folders of the wordpress installation the plugin was there but the problem was gone... So even thought the problem is gone I am not sure for the solution.
My suggestion to anyone with the same problem: Delete plugins not just deactivate.

Related

Wordpress ACF fields disappeared

I have been working with wp for a while now but just ran into a bug, that I can not fix with the information found in the internet.
I was editing a acf field. When I was finished writing into one of the fields, I mistakenly pressed enter. The page started reloading and all fields were gone. When going to the frontend, everything is displayed properly.
I tried to reactivate my ACF fields via the screen options what did not work. I inserted some code lines into my functions.php. or into the input.css because I thought maybe the right checkbox for the ACF fields to be displayed was missing. Nothing helped. Is there any other way to fix this issue.
thx in advance
greetings
I just come through this problem : for one of my field group, the fields box just disappeared at some point and I had no way no retrieve it thanks to the Wordpress Admin interface.
I don't know the reason why, but it appears that in my case, ACF registered some "unwanted" user meta in my database. (how is the question)
If you look inside your DB at the usermeta table content you will probably find some ACF entries like : metaboxhidden_acf-field-group or closedpostboxes_acf-field-group and maybe others...
The one causing trouble for me was meta-box-order_acf-field-group : I simply deleted the entry (but you can try editing it to remove the reference of your "lost" box) and the problem was solved.
Maybe too late to help you, but hope it can still help someone !
##EDIT##
Seems I may have a clue about how the box disappeared
Steps to reproduce :
Create a field group and associate it with whatever post type you have
Go create a whatever post (note : the Gutenberg editor is active on this edit page)
You should find your fields group at the bottom of the page
Try to move the group meta box above the Gutenberg editor (without success because it seems not possible)
Save your post
Come back to the edit page of the field group and refresh it
Tadaaa ! the fields group box is not available anymore
Go to your database, the usermeata table, you will find the entry causing the trouble again : meta-box-order_acf-field-group = a:3:{s:4:"side";s:32:"submitdiv,acf-field-group-fields";s:6:"normal";s:57:"acf-field-group-locations,acf-field-group-options,slugdiv";s:8:"advanced";s:0:"";}
I solved the problem by adding a custom script for the ACF with delete class closed on #acf-field-group-fields:
document.addEventListener("DOMContentLoaded", function(event) {
document.querySelector('#acf-field-group-fields').classList.remove('closed');
});

Cannot read property 'getCollectionByRoute' of undefined - Gutenberg wordpress

Gutenberg Editor In worpdress keep crashing from time ti time and i get the message "The editor has encountered an unexpected error".
When I open the console I get a React error that said:" Cannot read property 'getCollectionByRoute' of undefined".
Anyone have any idea what causes this problem?
I'm facing the same problem as you, so I think it's something related to the post categories. So as a workaround to allow you editing your posts you can clean your site cookies and the next time you edit your post don't expand the categories section. If you need it then use the quick edit.

woocommerce attributes not showing on front end

I have setup a Woocommerce store with hundreds of variable products (months ago). Everything has been working great with product variations/attributes so far, but today I got a message saying that customers are unable to pick a size for some of our products.
So, I have been looking into this, but I do not see why this is not working as intended...
I have set the attributes correctly on the back-end, I know this because it has been working as intended for the last 6+ months. I have also looked at the attributes & variations settings for these products, and they are all still set correctly.
Then, I double-checked to make sure the variation still had a price set, which it does.
Then, I checked the front-end of the site, and sure enough, the "size" attributes no longer show any options.
Any thoughts on why this might be? I have looked around stackoverflow a bit already... and the only thing I have found that I haven't tried yet, is: disabling all the plugins and reverting the site's theme to a default theme... I am really trying to avoid going down that road...
Sample URL (manually set product "Size" attributes on product page back-end):
https://www.worldequestrianbrands.com/product/contour-all-purpose-pad-with-bare-flaps/
Any/all help is greatly appreciated!
WordPress: 4.7.4 - WooCommerce: 3.0.5
Update #1:
Follow up:
After investigation, and an email from a fellow stackoverflow user, I have narrowed this down to a plugin version incompatibility with WooCommerce 3.0.5. Rolling back to WC 3.0.4 restored all the products' custom attributes to the front-end of the site. I am not sure what or why this issue happened, all I know is that rolling back WC was as a temporary workaround.
More Info:
When I first posted this issue on stackoverflow, I was running WC 3.0.5. When running that version, this was my experience:
I have Variable Products setup with multiple Custom Attributes (set for each product, not through the WooCommerce > Attributes settings admin-sidebar feature of WC).
If I went to edit a Variable Product with custom attributes, all of custom attributes showed up fine on the back-end, but only 1 of the custom attributes would not show any options on the front-end (e.g. "size" attribute).
Looking again at the back-end of the product, the size attribute is listed, with variations, and a set price.
I tried clicking "Update" on a product, just to see what would happen, and when the back-end page reloaded, the custom attribute I set was gone (e.g. "size").
So, I figured it wasn't loading that Custom Attribute for some reason, so I went to the proper: WooCommerce > Attributes, and set the "size" attributes there
Then went back to the variable products, and added the newly set "size" attributes, from the proper WooCommerce > Attributes that I setup
Clicked "Update" to commit the changes, and there we go, now the "size" attribute shows up correctly on the front-end
I manually updated over 100+ products this way
A fellow stackoverflow user emailed me and mentioned he had the same issue, but rolling back to WC 3.0.4 worked for him, as a "workaround"
I rolled WC back from 3.0.5 > 3.0.4, and boom, all the Custom Attributes we have set are now loading on the front-end of each product, as intended.
So, after all of that... I am still not sure exactly what is causing the issue, all I know is rolling back WC seems to allow certain Custom Attributes to be displayed again, on the front-end.
If I find out anything else, I'll be sure to update here!
Thank you again for any/all help with this! I am glad this 'workaround' is possible, for now, but the root of the issue is still unresolved.
I have not looked at any PHP or any other server logs yet, due to limited time, but I am happy to report any follow up info I can - or the actual issue AND solution! :)
Any other insights are greatly appreciated! I am still curious why this is happening...
Cheers!
Update #2:
This seems to be a known issue with WooCommerce 3.0.5, as stated on github
"We've identified the cause of the errors. This issue happens when you have a custom attribute with the same name as a global attribute. We're working on a fix now."

Wordpress/Woocommerce checkout page 500 error

Im getting 500 error page on my woocommerce store checkout page. I noticed that when cart is empty there is no error, only when I add products in it
the address is https://www.belizajec.si/webshop/checkout/
when debug mode enabled I get this error
Notice: register_sidebar was called incorrectly. No id was set in the arguments array for the "Translator For Header" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /home/apartkri/public_html/webshop/wp-includes/functions.php on line 4137
Fatal error: Class 'WC_Gateway_Paypal' not found in /home/apartkri/public_html/webshop/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php on line 105
thanks
Did you update to WooCommerce 3.0? Make sure the theme you are using is compatible with WooCommerce 3.0. If it's a plugin you are using for Paypal disable it first and see if thats the one causing an issue.
Seems like some incompatibility.
ok, the problem was solved by re-uploading all Woocommerce files over existing files on server.
This seems to be the plugin / theme conflict issue and to be honest cannot be judge directly.
However, there are some primary steps which you can follow, as below :-
Disable all plugins except "Woocommerce"
Activate WordPress default theme
After this check by following same procedure.
Let me know if I can help you further...

Why does WordPress allow multiple page-slugs in url without triggering 404?

The title is pretty self explanatory, but I'm trying to figure out why WordPress allows this or if it's a setting in .htaccess perhaps, but here's the example:
I have a page, lets say a "Contact" page with the slug of "contact-us".
I go to http://example.com/contact-us/ -- everything works normally
I go to http://example.com/contact-us/contact-us/contact-us/contact-us/contact-us/contact-us (I could do this a million times) and it does NOT trigger a 404 error!
Why is this? If I enter a random string of numbers, it instantly triggers 404.php, but just repeating the page-slug does not trigger a 404.
I would like the page-slug to not be able to be repeated over and over again and trigger a 404 if it even gets repeated once.
Has anyone else experienced this issue? Is it possibly a canonical link issue or a "nofollow". I just don't understand why WordPress is not seeing this as 404 material.
Thanks in advance for any replies, suggestions, and help.
I have found a way to solve my own problem. Today I noticed that I was running two WordPress builds on the same server but one went to 404 while the other would just go back to the page. Now I knew it was a theme specific issue.
The answer is really simple actually, it was a permalink issue. In order for me to get the behavior I was looking for, I had to select "Post Name" as my permalink settings.
I previously had a custom string of options for a different style display using "Custom Structure", which I'm assuming had the "failsafe" in it.
I'm willing to switch out the extra permalink styling options in favor of the 404.
Although, those that opt to use a custom permalink structure should see if this happens to you.

Resources