• Resolved NettSite

    (@nettsite)


    Hi,

    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.
    https://dev.caselaw.co.za/wp-admin/edit.php?post_type=case
    does not display at all.

    From page 2 onwards, it is perfect.
    https://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?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • I don’t think that the pagination has something to do with the CPT itself ( although I might be wrong here ) since you are able to change how many posts you can view per page from the Screen Options.

    So for an example you mean that when you are viewing the 1st list page you don’t have any links at all for the next ones ?

    I’m not able to reproduce the problem on my end.. Could you check your browsers console as well if there’s an error of some sort that might be breaking a script ?

    Thread Starter NettSite

    (@nettsite)

    Hi Xenos,

    Thanks for looking.

    I checked the console as you suggested, and no errors are being displayed. For good measure, I tried Firefox (I normally use Chrome) and that produced the same result.

    I must be doing something wrong in my plugin.

    Moderator bcworkz

    (@bcworkz)

    Nothing at all? A blank white screen? (AKA the “White Screen of Death” or WSoD ?? ) If so, there’s a PHP error somewhere. Check you error logs or define WP_DEBUG as true in wp-config.php. On that blank screen, once you reload it a message will appear telling you what and where the error is. Probably something along the lines of using $paged when it is not assigned a value. You should have code somewhere that if it’s not set, assign the value 1 to it.

    Do not leave WP_DEBUG defined as true for any extended period of time in a publicly accessible site, it’s a slight security risk.

    Thread Starter NettSite

    (@nettsite)

    Hi, no, not a blank screen – the page looks normal except that there is no pagination bit at the top and bottom of the list of posts. Sorry, I may not have been totally clear.

    It is a dev site, so debug is on and errors are being logged, but no errors come up while loading the page.

    • This reply was modified 7 years, 6 months ago by NettSite.
    Moderator bcworkz

    (@bcworkz)

    I’ve registered a CPT using your parameters and cannot replicate the behavior on a plain vanilla test site. (Making up my own values for the variables. They are all strings, so shouldn’t make any difference) There may be a plugin or theme conflict somewhere. Deactivate all plugins and switch to a default twenty* theme. Temporarily copy only your CPT registration code to the theme’s functions.php file. You should see that the pagination appears correctly. Begin reverting to your site’s normal configuration, one module at a time, reloading the list screen after each. When the pagination disappears again, the last activated module is the culprit.

    Thread Starter NettSite

    (@nettsite)

    Hi,

    Thanks. I have tried the theme/plugin thing and it doesn’t solve my issue – my CPT is registered by a plugin I wrote, so I must be doing something dumb.

    I found yesterday that the standard posts page behaves the same way, and works properly if I deactivate my plugin. Pages page works properly with my plugin activated.

    Your code above was only in the context of the CPT creation itself. But by your last post I had a thought that maybe you tried hooking into the columns with add_filter() to re-arrange them thus breaking it somewhere there maybe? We don’t have the full code so it’s hard to back-track what’s been done ?? .

    Thread Starter NettSite

    (@nettsite)

    Thank you for your help – I have found the offending function. Xenos pointed me in the right direction.

    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 https://dev.caselaw.co.za/search-page/

    Super ! Really glad that we managed to sort this out finally. Also that search is actually lightning fast.. 310k results in a matter of ms.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Pagination in wp-admin for CPT’ is closed to new replies.