I’ve taken over website from another developer and they used a plugin to generate a custom post types. The plugin is no longer maintained and sometimes courses an error 505 when try and load the plugins admin page. The front end site works fine. I also don't like having out of date plugins because of the security risk. ' I previously asked a question related to this issue which was solved about getting the properties of a custom post type created by a plugin so they I could re make it using register_post_type(). That was solved by Qaisar Feroz with get_post_type_object().

I have now recreated the post types and everything works fine in the back end. I can see all my posts that are custom post types. The only remaining problem is that one of the post types uses the standard Wordpress category as its taxonomy. Custom post types are not showing up on the category pages like they used to, if I was making the site from scratch I would use a custom taxonomy but all the posts and their links to the categories already exist. I have read that if a custom post type uses Wordpress' standard taxonomy's: tags & category you have to take extra steps for the custom post types to show up on the category archive pages. I tried several code snippets but every-time I use something like the one below my custom post types will display on the category page but none of my menus will display in the header or the footer. Its must be possible as it all worked fine with the plugin (Toolset Types)

My custom post type is called 'product'.

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if( is_category() ) {
    $post_type = get_query_var('post_type');
        $post_type = $post_type;
        $post_type = array('nav_menu_item', 'post', 'product'); // don't forget nav_menu_item to allow menus to work!
        return $query;

You don't need to return $query it is passed by reference.Have a look at the codex

The return statement might be shortcircuiting the page load. Try removing it.

  • Unfortunately remove the return did not work. Just to clarify my new post types are showing when I add the code, its just the menu in the header no longer shows and footer content does not load either (footer has a few menus in it to). – lomokev May 13 '19 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.