Skip to:
Content
Pages
Categories
Search
Top
Bottom

Related topics!


  • elsoar
    Participant

    @elsoar

    Hello beautiful people..
    Thanks for all the help.

    I have a request, is there any plugin or way to display related topics?

    Thanks in advance.

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

  • Robin W
    Moderator

    @robin-w

    The issue is defining what a ‘related topic’ is !


    elsoar
    Participant

    @elsoar

    Excuse me, sir. What do you mean?
    I mean related topics at the end of the topic or widgets.
    There are plugins that do this, but they do not work with bbpress. like: YARPP.


    Robin W
    Moderator

    @robin-w

    you’d need to ask yarpp what you need to do


    Robin W
    Moderator

    @robin-w

    I just added yarpp, it looks like it recognizes these as ‘buddypress topics’ – buddypress uses bbpress forum


    elsoar
    Participant

    @elsoar

    I MEAN ANY OTHER PLUGIN.
    OR ANY OTHER WAY.


    Robin W
    Moderator

    @robin-w

    Not that I know!


    Robin W
    Moderator

    @robin-w

    maybe look through these, bbpress simply uses custom post types of ‘forum’, ‘topic’ and ‘reply’, so any that will let you add custom posts types should be fine

    https://blog.hubspot.com/website/best-wordpress-related-post-plugins


    wpturk
    Participant

    @wpturk

    I’ve played with this today.

    If you are using tags in your topics, this will print the 5 related topics based on tags.
    (You need to put this in your functions.php)

    function aa_related_topics() {
    
            $topic_id = bbp_get_topic_id();
            $tags = wp_get_post_terms( $topic_id, bbp_get_topic_tag_tax_id(), array( 'fields' => 'ids' ) );
    
            $args = array(
                    'post__not_in' => array($topic_id),
                    'post_type'  => bbp_get_topic_post_type(),
                    'posts_per_page' => 5,
                    'orderby'   => 'rand',
                    'tax_query' => array(
                            array(
                                    'taxonomy' => bbp_get_topic_tag_tax_id(),
                                    'terms'    => $tags,
                            ),
                    ),
            );
    
            $my_query = new wp_query( $args );
    
            if( $my_query->have_posts() ) {
                echo '<div id="related"><h4>Related Posts</h4>';
                    while( $my_query->have_posts() ) {
                        $my_query->the_post(); ?>
                        <div>
    
                            <h5><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
    
                        </div>
                    <?php }
                    wp_reset_postdata();
                echo '</div>';
            }
    
    }
    add_action( 'bbp_template_after_single_topic', 'aa_related_topics' ); 

    imFiles
    Participant

    @imfiles

    This one works for bbpress: https://wordpress.org/plugins/contextual-related-posts/ if you want only related topics just go into Contextual Related Posts Settings and on the List tuning tab and on Post types to include select topic only. One thing it doesn’t have an automatic option to add the related items, so you need to added them either manually or the best way is with a fucntion.
    I use this one to add it after each topic:

    //add adsense after topic
    add_action( 'bbp_template_after_replies_loop', 'rew_other_topics' );
    function rew_other_topics () {
    	 $topic_id = bbp_get_topic_id() ;
    	 $forum_id = bbp_get_topic_forum_id($topic_id) ;
    	if ( function_exists( 'echo_crp' ) ) { echo_crp(); }
    }
Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar