WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.16k stars 4.05k forks source link

Authors and Categories List not Fully Dispalying #15994

Open petmyrhino opened 5 years ago

petmyrhino commented 5 years ago

Describe the bug When adding a new post (/wp-admin/post-new.php), in the section entitled Document, in the Author scroll box, I have only the first approximately 70 authors out of 150 that write for the site. I am missing half my list to choose from.

Similarly, in the Categories section, I am missing many of the potential categories that are usually listed.

However, if I go to All Posts (/wp-admin/edit.php), and I click quick edit, my categories appear as does my full list of authors.

I would like to restore this functionality to the new post (/post-new.php).

Can anyone please tell me what is going on and how to fix it?

Thank you.

Note that i just moved from a very outdated Go Daddy self directed Linux hosting to Go Daddy Managed WordPress hosting. I was pretty old school and finally caved into getting my ssl and all that.

To reproduce Steps to reproduce the behavior:

  1. Go to /wp-admin/post-new.php
  2. Click on Document, Click on Authors
  3. Scroll down to find authors whose names come after Nadiya B
  4. The names are not there

Expected behavior I expect to see all the authors listed.

Screenshots

Additional context

Oops that was the wrong screenshot...

Screen Shot 2019-06-04 at 9 41 55 PM
mwidmann commented 5 years ago

This is bothering me too. It just doesn't make sense to limit the displayed authors to 100 entries. At least for the categories there's a way of searching for the others.

Until this is fixed, I added the following filter to one of my mu-plugins to remove the limit to 100 users and display all of them.

add_filter( 'rest_user_query', function( $prepared_args, $request ) {
    if ( array_key_exists( 'who', $prepared_args ) && array_key_exists( 'number', $prepared_args ) &&
        'authors' === $prepared_args['who'] && 100 === $prepared_args['number']
    ) {
        unset( $prepared_args['number'] );
    }
    return $prepared_args;
}, 10, 2 );

a bit hackish, I know, but it can be easily removed once this issue is fixed.

serkan-asquared commented 3 years ago

@mwidmann , I have tried various solutions and filters but whenever I use the filter, I get an empty response. Are you still using the same filter?

mwidmann commented 3 years ago

@serkan-asquared yes, still using it and seems to work quite fine in WordPress 5.7. It is in the starter file of one of the plugins we have enabled. Not inside any hook or action. Maybe you call it at a wrong time?

EdwardBock commented 3 years ago

+1 from me. I think it is totally fine to initially load only some authors or categories but please load more if we scroll to the end of the list.

mwidmann commented 2 years ago

A small update. With WordPress 5.8 there's a way to filter the list by typing a partial name of the author. This should partially solve the initial issue with the list not being complete.

The filter I posted here introduced a new set of issues as unsetting $prepared_args['number'] led to a division by zero warning in class-wp-rest-users-controller.php. While not breaking the functionality, it is still a bad thing to have this lying around.

Therefore the new version is:

// removes the limits applied to calls to the users rest api to avoid issues with gutenberg not showing all
// registered editor users. see https://github.com/WordPress/gutenberg/issues/15994
add_filter( 'rest_user_query', function( $prepared_args, $request ) {
    if ( array_key_exists( 'who', $prepared_args ) && array_key_exists( 'number', $prepared_args ) &&
        'authors' === $prepared_args['who'] && 100 === $prepared_args['number']
    ) {
        $prepared_args['number'] = 5000;
    }
    return $prepared_args;
}, 10, 2 );

5000 is just an arbitrary high number which will never be reached in our case.