0

I have created a CPT using register_post_type with the following args:

  "label" => $aLabels['name'],
  "labels" => $aLabels,
  "description" => "",
  "public" => true,
  "publicly_queryable" => true,
  "show_ui" => true,
  "show_in_rest" => false,
  "rest_base" => "",
  "has_archive" => true,
  "show_in_menu" => true,
  "exclude_from_search" => true,
  "capability_type" => "post",
  "map_meta_cap" => true,
  "hierarchical" => false,
  "rewrite" => array("slug" => $slug, "with_front" => true),
  "query_var" => true,
  "menu_icon" => site_url('/wp-content/uploads/icon.png'),
  "supports" => array("title", "editor", "excerpt", "custom-fields"),
  "taxonomies" => array('court', 'rating', 'categorisation'),

Everything works perfectly except pagination on the first page of the admin post list i.e.

http://dev.caselaw.co.za/wp-admin/edit.php?post_type=case

does not display at all.

From page 2 onwards, it is perfect.

http://dev.caselaw.co.za/wp-admin/edit.php?post_type=case&paged=2

I have Googled the world and can’t find a similar problem, never mind a solution! Can anyone make a suggestion?

  • Any plugins/themes interfering? – birgire Sep 12 '17 at 8:45
  • Thanks for having a look, but unfortunately, that's not it - tried with Twenty Fifteen and only the plugin which creates the CPT. – NettSite Sep 13 '17 at 10:18
  • Strange, does the cpt slug matter? Any errors? Does it work for other post types, like post and page? – birgire Sep 13 '17 at 13:48
  • Extra strangeness - I checked pages and posts, and pages work fine, but posts have the same issue as the cases (the CPT). If I deactivate the cases plugin, posts work fine, so there is clearly something wrong with my plugin. – NettSite Sep 14 '17 at 15:14
  • Yes sounds like the plugin is causing it, but it's hard to say what it is.Try e.g. to remove stuff from it (in small steps) until it works again? – birgire Sep 14 '17 at 16:41
0

Thank you for your help - I have found the offending function.

The plugin is meant to manage about 400,000 case files and provide a fast search. In order to manage the search on the front-end of the site, I need to manipulate the number of results found for any given search, so I added a filter at "found_posts" to do that, and that was breaking the pagination on the backend.

I added "if(is_admin()) return;" to that function and everything is hunky dory.

If you are interested in seeing a fast search in action, look for "dismissal" or something on http://dev.caselaw.co.za/search-page/

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.