Skip to:
Content
Pages
Categories
Search
Top
Bottom

List of topic pages next to forum topic (bp_the_topic_pagination)

  • Avatar of notpoppy
    notpoppy
    Participant

    @notpoppy

    In a forum, I would like to have a list of the pages in each topic next to the link to it. That way users can jump into the last page of a topic if they wish without having to go through the first page.

    In topic.php (groups/single/forum) the pagination is created using:

    Is there a way to make this work in forums-loop.php to create the result I’m trying to achieve?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Avatar of notpoppy
    notpoppy
    Participant

    @notpoppy

    Am still trying to find out how to do this. I’ve had a look at various themes and not found one that has it.

    Can anyone at least tell if it’s possible to do this with Buddypress?

    Avatar of notpoppy
    notpoppy
    Participant

    @notpoppy

    I still can’t figure out how or if this is possible – can anyone help?

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    Anything’s possible ;)

    You won’t be able to do it with `bp_the_topic_pagination()` because that function requires that you are inside of a single topic loop, which you’re not.

    Try something like:

    `global $forum_template;

    $per_page = 5;
    $total_posts = $forum_template->topic->topic_posts;

    $pag_links = paginate_links( array(
    ‘base’ => add_query_arg( array( ‘topic_page’ => ‘%#%’, ‘num’ => (int) $per_page ), bp_get_the_topic_permalink() ),
    ‘format’ => ”,
    ‘total’ => ceil( (int) $total_posts / (int) $per_page ),
    ‘mid_size’ => 1
    ) );
    echo $pag_links;`

    Avatar of notpoppy
    notpoppy
    Participant

    @notpoppy

    @boonebgorges Thanks for the reply!

    I’m not quite sure how to use your solution, though. is it something that goes in functions.php? If so, how do I then use it in the theme?

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    If you want to use it in a theme, try putting it in a function wrapper and then calling that function in your template. In functions.php:

    `function bbg_forum_pag() {
    global $forum_template;

    $per_page = 5;
    $total_posts = $forum_template->topic->topic_posts;

    $pag_links = paginate_links( array(
    ‘base’ => add_query_arg( array( ‘topic_page’ => ‘%#%’, ‘num’ => (int) $per_page ), bp_get_the_topic_permalink() ),
    ‘format’ => ”,
    ‘total’ => ceil( (int) $total_posts / (int) $per_page ),
    ‘mid_size’ => 1
    ) );
    echo $pag_links;
    }`

    Then in your template:

    Avatar of notpoppy
    notpoppy
    Participant

    @notpoppy

    @boonebgorges Works perfectly – thanks very much!

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

You must be logged in to reply to this topic.