Graham
Graham

Reputation: 162

Wordpress admin area search bug "invalid post type"

I'm noticing a strange bug across several Wordpress sites and was wondering who else has experienced it - and how they solved it, ideally!

If I click All Pages and search for anything it works fine. If I try to search again from the results page, though, it spits out an "invalid post type" error.

The solution has been to click to view All Posts and start again - but there must surely be a fix?

Thanks! G

Upvotes: 0

Views: 1946

Answers (2)

Nik Horse
Nik Horse

Reputation: 183

For me the was issue was with the active theme, search in your functions.php code like 'pre_get_posts' , then you will see something like:

add_filter( 'pre_get_posts', 'my_posts' );

You must replace it with:

if(!is_admin()) {
add_filter( 'pre_get_posts', 'my_posts' );
}

For me it helped, but before this try to turn off plugins one by one to be sure that the problem was not from the plugins side.

Upvotes: 5

kkarpieszuk
kkarpieszuk

Reputation: 516

It looks like conflict with some plugin or your theme: clean WordPress does not have this bug.

To debug, disable all plugins and check if it will be fine then. If it fixes your issue, start to enable plugins one by one to find "guilty" (you can use divide and conquer strategy to speed up this)

What do you have in url of page, when you see your error? It should have:

...&post_type=page&...

Do you have it?

Upvotes: 1

Related Questions