Support » Plugin: BuddyPress Docs » Pagination problem

  • Resolved jacobwindham12

    (@jacobwindham12)


    When viewing docs in a profile or on a group page, the pagination does not work. The url changes to …/page/2/ but the list of documents does not change.

    It works fine on https://peglearning.com/docs/

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

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

    (@dcavins)

    Hi @jacobwindham12-

    We have previously solved issues very much like the one you describe, so it sounds familiar.

    However, I’ve tested the current version, and cannot recreate the problem you’re seeing when visiting a profile’s docs, like: http://bptest.local/members/two/docs/started/page/2/

    Are you using the current version of BP Docs? Can you flush your permalinks (visit the settings > permalinks page and hit “save”–you don’t need to change anything). If the problem persists, it could be an issue with your theme. Can you switch to something like Twenty Nineteen and see if the issue is fixed?

    -David

    jacobwindham12

    (@jacobwindham12)

    Thanks for the quick reply. I’ll test further later tonight. I’m using the WPLMS theme and saw that it was having trouble with previous versions.

    jacobwindham12

    (@jacobwindham12)

    I’m using the latest version of BP Docs. I’ve flushed the permalinks. I made a clone install and disabled all plugins but Buddypress, BP Docs, and used the 2019 theme. The pagination is still broken.

    Active plugins:
    http://prntscr.com/m8zvdt

    2019 theme on BP Docs page showing “Page 2” with the navigation showing page one and “showing docs 1-6 of 8”

    https://prnt.sc/m8zvj1

    Plugin Author David Cavins

    (@dcavins)

    Hi @jacobwindham12-

    Thanks for testing the issue thoroughly. Can you capture the query arguments as the page is being built? Here’s an example filter to capture the args:

    
    add_filter( 'bp_docs_pre_query_args', function( $args ) {
        $towrite = PHP_EOL . '$args: ' . print_r($args, true);
        $fp = fopen('bp_docs_args.txt', 'a');
        fwrite($fp, $towrite);
        fclose($fp);
    
        return $args;
    }, 999 );

    For example, my site’s args look like this:

    $args: Array
    (
        [post_type] => bp_doc
        [tax_query] => Array
            (
            )
    
        [meta_query] => Array
            (
            )
    
        [orderby] => modified
        [order] => DESC
        [paged] => 2
        [posts_per_page] => 10
        [author] => 1
        [post_status] => Array
            (
                [0] => publish
                [1] => trash
                [2] => bp_docs_pending
            )
    
    )

    I noticed that your site was showing 6 items per page, so I tried changing my setting at Settings > Reading > “Bog pages show at most,” but pagination is still working on my test installation. Is that how you set your per-page number?

    What version of WP are you using?

    jacobwindham12

    (@jacobwindham12)

    WP version 5.0.3

    I am able to change the amount show by changing settings>reading>blog pages

    I’m not sure if the theme changes anything.

    Where should I add the filter? in functions.php?

    Plugin Author David Cavins

    (@dcavins)

    Yep, functions.php would be fine, as would bp-custom.php. https://codex.buddypress.org/themes/bp-custom-php/

    The file that is generated should end up in the root directory of your site.

    
    $args: Array
    (
        [post_type] => bp_doc
        [tax_query] => Array
            (
            )
    
        [meta_query] => Array
            (
            )
    
        [orderby] => modified
        [order] => DESC
        [paged] => 0
        [posts_per_page] => 6
        [author] => 1
        [post_status] => Array
            (
                [0] => publish
                [1] => trash
                [2] => bp_docs_pending
            )
    
    )
    
    $args: Array
    (
        [post_type] => bp_doc
        [tax_query] => Array
            (
            )
    
        [meta_query] => Array
            (
            )
    
        [orderby] => modified
        [order] => DESC
        [paged] => 0
        [posts_per_page] => 6
        [author] => 1
        [post_status] => Array
            (
                [0] => publish
                [1] => trash
                [2] => bp_docs_pending
            )
    
    )
    
    $args: Array
    (
        [post_type] => bp_doc
        [tax_query] => Array
            (
            )
    
        [meta_query] => Array
            (
            )
    
        [orderby] => modified
        [order] => DESC
        [paged] => 0
        [posts_per_page] => 6
        [author] => 1
        [post_status] => Array
            (
                [0] => publish
                [1] => trash
                [2] => bp_docs_pending
            )
    
    )
    
    Plugin Author David Cavins

    (@dcavins)

    Well, that’s weird that the paged is getting steamrolled. Can you try this code?

    add_filter( 'bp_docs_pre_query_args', function( $args ) {
        global $wp_query;
    
        $towrite = PHP_EOL . '$args paged: ' . print_r($args['paged'], true);
        $towrite .= PHP_EOL . '$wp_query paged: ' . print_r($wp_query->get( 'paged' ), true);
        $fp = fopen('bp_docs_args.txt', 'a');
        fwrite($fp, $towrite);
        fclose($fp);
    
        return $args;
    }, 999 );

    I’m assuming that you’re trying this code on the installation that only has BP + BP Docs activated. And it might be worth flushing permalinks again, because the pagination arguments are picked up by rules set there.

    Thanks!

    No luck. I created a bp-custom.php at …/wp-content/plugins and added the code on a test installation with bp + bp docs + 2019 theme.

    Plugin Author David Cavins

    (@dcavins)

    What was output to the bp_docs_args.txt file? We’re still trying to figure out what is stomping the pagination arguments.

    Thanks!

    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    $args paged: 0
    $wp_query paged: 0
    Plugin Author David Cavins

    (@dcavins)

    Does pagination work on your blog? (I ask because BP Docs’ “started by me” screen is using WP’s built-in pagination rules, not adding custom rules.) You can check to see which of WP’s rewrite rules are being used by installing a plugin called “Query Monitor” and clicking the “Request” link as shown in this screenshot: https://imgur.com/a/HsIysBA

    Here are the expected results from my test installation:
    Request
    members/admin/docs/started/page/2

    Matched Rule
    (.?.+?)/page/?([0-9]{1,})/?$

    Matched Query
    pagename=members%2Fadmin%2Fdocs%2Fstarted
    &paged=2

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.