Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Topic Loop


  • Babblebey
    Participant

    @babblebey

    Hello there,

    Firstly thank you for viewing this thread, really appreciate.

    I am trying to create a topic loop to display in my in development theme. I have created a template part in my theme-directory/bbpress/omna-forumthreads see below:

    <?php
    
    /**
     * Single Thread
     *
     * @package bbPress
     * @subpackage Theme
     */
    
      $threadURL = bbp_topic_permalink();
      $threadTitle = bbp_topic_title();
      $threadTIme = bbp_topic_post_date();
      ///////////////// Thread Author Avatar URL ////////////////////////
      $user_id = bbp_get_user_id( $user_id );
      $authorAvatarURL = get_avatar_url( $user_id, 300 );
      ///////////////////////////////////////////////////////////////////
      $threadVoiceCount = bbp_topic_voice_count();
    
    ?>
    
    <div class="swiper-slide-item">
        <div class="icon-author" style="background-image: url('<?php echo $authorAvatarURL; ?>'); background-image: -webkit-image-set(url('<?php echo $authorAvatarURL; ?>') 1x, url('<?php echo $authorAvatarURL; ?>') 2x);">
        </div><<?php echo $threadURL; ?>"><?php echo $threadTitle; ?></a></h2>
            <time class="data" datetime="<?php echo $threadTIme; ?>"><?php echo $threadTIme; ?></time>
            <span class="views"><i class="fa fa-comment-alt"></i><?php echo $threadVoiceCount; ?></span>
        </div>
    </div>
    

    And i believe this should work, But currently i have issues with the loop that should display it by driving the content from the template part. Here is my loops:

    <div class="swiper-wrapper">
        <div class="swiper-slide">
           <div class="swiper-slide-container">
              <?php
                 if ( bbp_has_topics() ):
                    while ( bbp_topics() ) : bbp_the_topic();
                       bbp_get_template_part( 'bbpress/omna', 'forumthreads' )
                    endwhile;
                 endif;
              ?>
           </div>
        </div>
     </div>

    Now i get a pass error:

    Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE) in C:\wamp\www\omna\wp-content\themes\omna\page-home.php on line 143

    I have also tried the curly brace {} type of IF & WHILE expressions, still a parse error..

    Please Help.

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

  • Robin W
    Moderator

    @robin-w

    bbp_get_template_part( 'bbpress/omna', 'forumthreads' )
    should read
    bbp_get_template_part( 'bbpress/omna', 'forumthreads' ) ;

    you missed a ‘;’ !


    Babblebey
    Participant

    @babblebey

    I just found out brother… On coming here to reply my thread in signal for I already solved it.. I found you…. Thank You very much for your feedback


    Babblebey
    Participant

    @babblebey

    Well just incase other people finds this thread.. My Template Part had bugs too.. Here is the one that worked:

    <?php
    
    /**
     * Single Thread
     *
     * @package bbPress
     * @subpackage Theme
     */
    
      // $threadURL = bbp_topic_permalink(); // Deprecated ////
      // $threadTitle = bbp_topic_title(); // Deprecated ////
      // $threadTIme = bbp_topic_post_date(); // Deprecated ////
      ///////////////// Thread Author Avatar URL ////////////////////////
      $user_id = bbp_get_user_id( $user_id );
      $authorAvatarURL = get_avatar_url( $user_id, 300 );
      ///////////////////////////////////////////////////////////////////
      // $threadVoiceCount = bbp_topic_voice_count(); // Deprecated ////
    
    ?>
    
    <div class="swiper-slide-item">
        <div class="icon-author" style="background-image: url('<?php echo $authorAvatarURL; ?>'); background-image: -webkit-image-set(url('<?php echo $authorAvatarURL; ?>') 1x, url('<?php echo $authorAvatarURL; ?>') 2x);"></div>
        <a href="<?php bbp_topic_permalink(); ?>"><?php bbp_topic_title(); ?></a></h2>
        <time class="data" datetime="<?php bbp_topic_post_date(); ?>"><?php bbp_topic_post_date(); ?></time>
        <span class="views"><i class="fa fa-comment-alt"></i><?php bbp_topic_reply_count(); ?></span>
    </div>

    The bbPress Functions does not want to be assigned to variable as Unlike the GET_ they do not return values, they echo.

    Thanks.

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