• Resolved jstneti

    (@jstneti)


    I have made a custom User taxonomy and I’m able to display users based on that taxonomy with author.php (single user) and with taxonomy-customtax.php (user archive).

    Now the problem comes with the pagination in the archive page.
    I’m using the WP_User_Query to display Users and everything works ok as long as I set the ‘pre_get_posts’ to half less than the ‘number’ of Users per page.

    If I set the same number (1) and there are 7 Users to display, I get 7 pages with 1 user on each, but the fifth (and sixth and seventh) page returns a 404.

    Anyone knows what could be the issue?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    What does WP_User_Query have to do with a taxonomy? Taxonomies are for posts, as are archive templates and posts per page. Of course you can query for user objects anywhere you want, but WP_User queries do not have anything to do with taxonomies or post pagination. WP_User_Query has its own pagination arguments, but they do not work exactly like post pagination, “number” is used in place of “posts_per_page”. “paged” works the same way, but the paged from a posts archive is unrelated to the paged in a WP_User_Query.

    It’s hard to say without seeing the code used, but it sounds like you’ve inappropriately intermixed post arguments in a user query.

    Thread Starter jstneti

    (@jstneti)

    Here is my code to create a User Taxonomy, author & archive page: https://gist.github.com/jstneti01/c276d1586a7672a79e1cd62e66dd3fba

    I had help with this code: https://gist.github.com/portfola/10750784#file-taxonomy-artist-php

    Now everything works fine. In the file user-taxonomy.php on line 116 I had to set 1 post per page. This way I get all of my pages. The real number is set in the taxonomy-user_cat.php file on line 10.

    Previously I have set this two numbers the same and it didn’t work, but as log as the number in pre_get_posts is set to 1, it works.
    So I guess I don’t need any more help.

    Thanks anyway

    Thread Starter jstneti

    (@jstneti)

    Closing this.
    I eneded up not using this approach because client decided to go another way.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_User_Query displays only half Users in pagination’ is closed to new replies.