Pulled threads are repeating the last ...

LPH

Well-known member
RESOLVED: There was a missing anchor being closed.

This is the code I've been using but realized the last post is being repeatedly pulled - up to 3 times:

Code:
    <div class="forum_posts one-third">  
      
      <h3>latest posts from our community</h3>
      
      <?php
      
      /* Script to pull the latest posts from the XF Forum */  
      
       $nodeModel = XenForo_Model::create('XenForo_Model_Node');
        
      $db = XenForo_Application::getDb();
      
      if (!$db) {
      die('This script did not connect to the database' . mysql_error());
      }
      
      $thread_qry = "
        SELECT thread_id, title, last_post_date FROM `xf_thread`
        ORDER BY `last_post_date` DESC
        LIMIT 5
             ";
      
      $threads = XenForo_Application::get('db')->fetchAll($thread_qry);
      
      foreach ($threads AS $thread) {
      echo ("<div class='entry-meta'><a href='http://www.tuxreports.com/community/" . XenForo_Link::buildPublicLink('threads', $thread) . "'>" . XenForo_Helper_String::wholeWordTrim($thread[title], 40) . "</div>");
      }
      
      ?>
     </div>

This gives rise to :

Code:
<div class="forum_posts one-third">
<div class="entry-meta">
<a href="http://www.tuxreports.com/community/threads/the-changing-roles-of-u-s-soldiers-in-afghanistan.519208/"></a>
</div>
<a href="http://www.tuxreports.com/community/threads/the-changing-roles-of-u-s-soldiers-in-afghanistan.519208/"></a>
</div>

I keep looking at the PHP and trying to figure out why the same forum posts are being pulled. Can anyone point me in the right direction? Do you see an obvious error that causes this repetition?

You can see it live on www.tuxreports.com in the footer - right side. The left side pulling resources works fine.
 
Last edited:
Top Bottom