• Hello!

    I would like to change the number of “pages” to show on each side of the “current page” in the pagination links. The issue I’m having is that it’s showing 2 on each side of the “current page”. This is not practical and/or working for users on phone, since the buttons in the pagination is outside the screen.

    I had a similar issue with the Global Search plugin, but in this case I managed to find the piece of code for that to work (set to 1 on each side and not 2).

    I’ve looked into the code and can’t seem to find anything anywhere (where logic applies lol) where I could adjust the pagination pages/settings.

    Would it be possible to fix this with a snippet code (and not change the code directly) – if not – then what files do I need to change in order to adjust the pagination.

    This goes for both the “docs main directory” and the “user docs – buddypress tabs”.

    Thank you! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Cavins

    (@dcavins)

    Sure, check out the filter bp_docs_paginate_links at https://github.com/boonebgorges/buddypress-docs/blob/master/includes/templatetags.php#L1364

    Check out the end_size argument of paginate_links: https://developer.wordpress.org/reference/functions/paginate_links/

    Thread Starter GyziieDK

    (@dreampixel)

    I just found that, but can’t seem to make it work.

    This should be the only section changed – correct?

    function bp_docs_paginate_links() {
    global $bp, $wp_query, $wp_rewrite;

    $page_links_total = $bp->bp_docs->doc_query->max_num_pages;

    $pagination_args = array(
    'base' => add_query_arg( 'paged', '%#%' ),
    'format' => '',
    'prev_text' => __( '«', 'buddypress-docs' ),
    'next_text' => __( '»', 'buddypress-docs' ),
    'total' => $page_links_total,
    'end_size' => 2,
    );

    if ( $wp_rewrite->using_permalinks() ) {
    $pagination_args['base'] = apply_filters( 'bp_docs_page_links_base_url', user_trailingslashit( trailingslashit( bp_docs_get_archive_link() ) . $wp_rewrite->pagination_base . '/%#%/', 'bp-docs-directory' ), $wp_rewrite->pagination_base );
    }

    $page_links = paginate_links( $pagination_args );

    // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    echo apply_filters( 'bp_docs_paginate_links', $page_links );
    }
    • This reply was modified 1 year, 2 months ago by GyziieDK.
    Thread Starter GyziieDK

    (@dreampixel)

    I think I got it now, just had to add the option for “mid_size” and set this to 1 in order to make it fit into the page from what I can tell. 🙂

    Thank you! 🙂

    Thread Starter GyziieDK

    (@dreampixel)

    Oh wait – not quite fixed! 🙂

    I’ve got 20+ pages and the issue now is that it’s adding the […] on both sides.
    So when I’m on page 4 (as an example) it shows the following:

    [<][1][…][3][4][5][…][20][>]

    Because of the […] (ellipsis) buttons it is still a bit too wide for a phone screen.

    How can I fix this?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘BuddyPress Docs – Pagination’ is closed to new replies.