1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.
  3. Please make sure that you have registered and verified your email address prior to leaving comments.
  4. Our "baby tux" logo was originally drawn in early 2000 and cleaned up in January 2013.
  5. Tux Reports is celebrating 20 years of service on the Internet.

HowTo: Show a XenForo thread in a WordPress Page

Promote a XenForo first post in a thread in a WordPress Page

  1. LPH
    This little project is not clean but functions manually by changing the $forum_id in the PHP code added to the template file. The latest post in the forum is promoted to the WordPress page.

    Step One: Build the WordPress template

    Template Name: xffrontpage
    get_header(); ?>
    <div id="primary">
        <div id="content" role="main">
            <div id="mainstory">
    XenForo_Model::create'XenForo_Model_Thread' );
    $conditions = array();
    $fetchOptions = array(
    'join' => XenForo_Model_Thread::FETCH_FIRSTPOST,
    'order' => 'post_date',
    'orderDirection' => 'desc',
    'limit' => 1);
    $forum_id 186// Set a forum_id
    $threads $threadModel->getThreadsInForum$forum_id$conditions$fetchOptions ); // 6 is the node
    foreach ( $threads AS $threadId => $thread ) {
                        if ( 
    $threadModel->canViewThread$thread$thread ) ) {
    $formatter XenForo_BbCode_Formatter_Base::create();
    $parser = new XenForo_BbCode_Parser($formatter);
    $html $parser->renderXenForo_Helper_String::wholeWordTrim$thread['message'] , 140 ) );
                                echo (
    '<div class="entry-meta subHeading categoryStrip"><a href="' XenForo_Link::buildPublicLink('canonical:threads'$thread) . '">' XenForo_Helper_String::wholeWordTrim($thread['title'], 48) . '</a> <br /><br /></div>');
    $html .'<br /><hr>';
            </div><!-- #mainstory -->
        </div><!-- #content -->
    </div><!-- #primary -->
    <?php get_footer(); ?>
    Step Two: Save this file in the child theme directory.

    Step Three: Create a WordPress Page, choose the template xffrontpage


    Live Demonstration