• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.
Resource icon

HowTo: Add a dynamic footer to WordPress

Add the following code to the footer.php file for a WordPress child theme. Never modify an original theme file.

PHP:
    <div class="forum_footer">
    
<div class="forum_posts_leftside">

    <h3>latest tux reports network resources</h3>

<?php
 
/* Script to pull the latest updated resources from the XF Resource Manager*/
 
/** @var $resModel  XenResource_Model_Resource */
$resModel = XenForo_Model::create('XenResource_Model_Resource');
$fetchOptions = array(
'limit' => 5,
'order' => 'resource_date',
'direction' => 'desc'
);
 
$rmupdates = $resModel->getResources(array(), $fetchOptions);
 
foreach ($rmupdates AS $rmupdate)
{
        echo ("<div class='entry-meta'><a href='http://community.tuxreportsnetwork.com/" . XenForo_Link::buildPublicLink('resources', $rmupdate) .    "' >" . XenForo_Helper_String::wholeWordTrim($rmupdate['title'], 55) . "</a> <br /></div>"); // Echo the title with a link.
}
 
?>

</div>

<div class="forum_posts">    
    
    <h3>latest posts from our community</h3>
    
    <?php
    
    /* Script to pull the latest posts from the XF Forum */    
        
    $db = XenForo_Application::getDb();
    
    if (!$db) {
    
        die('This script did not connect to the database' . mysql_error());
    
    }
    
    $thread_qry = "
            SELECT * 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://community.tuxreportsnetwork.com/" . XenForo_Link::buildPublicLink('threads', $thread) .    "' >" . XenForo_Helper_String::wholeWordTrim($thread['title'], 48) . "</a> <span style='float:right; margin-right:60px'>Viewed: "  .$thread['view_count'] .       "</span><br /></div>"); // Echo the title with a link. 
     
    }
    
    ?>

</div><!-- Latest Forum Posts -->

<?php } ?>

    </div><!-- Forum Footer -->


    </div><!-- #main -->

Modify the links to the XenForo community. Test. Enjoy.

This same code may be used in the skin for MediaWiki.
Author
LPH
Views
480
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from LPH

Top