Skip to:
Content
Pages
Categories
Search
Top
Bottom

how to make the post sequences only specific to a single topic?

  • @wenlujon

    Participant

    I notice there’s post sequence in every post (at the top right corner, #[ids], and this is a link), which is necessary for a forum.
    however, the strange thing is that it’s for the forum wide! how to make the sequence starts from 1 for a specific topic? and every reply the count increases by 1.

Viewing 9 replies - 1 through 9 (of 9 total)
  • @robin-w

    Moderator

    bbpress uses custom post types in wordpress.

    Every wordpress post gets a unique number, as do edits and other stuff.

    so if you posted a forum topic it might get say id #1000, then a wordpress blog would get the next number #1001, the say a reply to a different forum topic orum topic #1002, then if you create a new page that would get #1003, then the first response the actual forum topic would get #1004

    You’d need to write a whole new numbering system to make your request work !

    @wenlujon

    Participant

    where’s the file which displays the number?
    I still think there’s way. for example, by remapping.

    1. define a meta data for a specific topic (for example, topic_id)
    2. remap the topic_id to the real id
    3. display the topic_id instead of the real id
    4. increase the topic_id by 1 every reply
    5. still keep the link to the real id, so when you click the topic_id, it actually points to the real id.

    @robin-w

    Moderator

    with code anything is possible !

    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-reply.php

    line 27

    @robin-w

    Moderator

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-reply.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-single-reply.php

    bbPress will now use this template instead of the original, so you can amend this one

    @wenlujon

    Participant

    looks like loop-single-reply.php is a single reply entry, which file invokes it (in a loop way),
    if i can find the caller, maybe I can set the meta data in the caller every time it loops:

    
    $index=1
    while (replies)
         set meta data (topic_id) to $index 
         load loop-single-reply.php
              get meta data (topic_id) in loop-single-reply.php
         $index++
    

    @wenlujon

    Participant

    ok, i got it (loop-replies.php):

                            <?php $count=1; while ( bbp_replies() ) : bbp_the_reply(); ?>
                                    <?php
                                             $post_id = get_the_ID();
                                             //save the new count
                                             update_post_meta($post_id, 'bbp_seq_test', $count) ;
                                    ?>
    
                                    <?php bbp_get_template_part( 'loop', 'single-reply' );
                                         
                                             $count = $count + 1 ;
                                    ?>
    
                            <?php endwhile; ?>
    

    and define a function show_seq()

    
          $post_id = get_the_ID();
          $count   = get_post_meta( $post_id, 'bbp_seq_test', true );
    
            echo $count;
    
    

    and then in loop-single-reply.php
    ` <a href=”<?php bbp_reply_url(); ?>” class=”bbp-reply-permalink”>#<?php show_seq(); ?></a>
    `

    and it works!

    please take a look!

    http://bbs.circday.com/forums/topic/%E6%B5%8B%E8%AF%95%E6%B0%B4%E5%8D%B0

    @robin-w

    Moderator

    great – glad you’re fixed !

    @robkk

    Moderator

    @wenlujon

    you could also edit loop-single-reply.php in your child theme and just replace

    <a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_id(); ?></a>

    with

    <a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_position(); ?></a>

    that should work the same way.

    @wenlujon

    Participant

    great, that’s simple enough.

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