Xenforo inside a Wordpress page.

OldCoals

Active member
How easy is it, or is it even possible to insert Xenforo into a Wordpress site?

I don't need it to share data, I just want the Wordpress header and footer so to speak to "wrap" the forum.
 
Next, is if you want to pull the latest forum posts and place them in your theme file (like the footer or sidebar - no widget needed).

Code:
<div class="forum_posts">    
    
    <h3>The following posts are 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)
    {
            $latestthreads[$thread['thread_id']] = array(
            'id' => $thread['thread_id'],
            'title' => $thread['title'],
            'url' => XenForo_Link::buildPublicLink('canonical:threads', $thread),
            'replycount' => $thread['reply_count'],
            'dateline' => $thread['post_date'],
            'viewcount' => $thread['view_count']
            );
     
            echo ("<div class='entry-meta'><a href='/community/" . XenForo_Link::buildPublicLink('threads', $thread) .    "' >" . $thread['title'] . "</a> Viewed: "  .$thread['view_count'] .       "<br /></div>"); // Echo the title with a link. 
     
    }
    
    ?>

</div><!-- Latest Forum Posts -->
 
Finally, pull the xenforo_thread_url so you may link to it in the forum.

Code:
<?php

if (function_exists('xenforo_thread_url')) {


if (comments_open() && post_type_supports(get_post_type(), 'comments')) :
    $link = xenforo_thread_url();
    if ($link != '') {
        ?>
        <p><a href="<?php echo xenforo_thread_url(); ?>">A copy of this story is in the forums.</a></p>
        <?php
    } else {
        ?>
        <p><?php _e('Comments are closed.', 'twentyeleven'); ?></p>
    <?php } endif;
}
?>

 <?php comment_form(array('must_log_in'=>'First <a href="/community/login">Login In or Sign Up</a> then add your reaction.', 'title_reply'=>'Post Your Comment.')); ?>

This allows you to simply replace the default WP comment system, add in LiveFyre or Disqus, etc. But the LiveFyre and Disqus comments will not be linked within the forum.

Night all.
 
Currently working on something to post from XF to WP, but it will require the XenScripts bridge if you would like to link the thread and WP post, so they share comments.
 
  • Like
Reactions: LPH
I am not sure how xenscripts does it but for our custom bridge I just store the threadid in WordPress' post metadata. Makes it easy to work with especially since the native WP functions support querying by metadata fields.
 
Great code snippets lph, thanks for sharing.

I think I'm going to have to take earlier advice and cut some code into the XF theme for the time being as lack the XF experience to make a start developing a bridge, would happily help support someone in making this reality though and contributing to the fund.

Cheers,
Paul
 
How about something simple like when an account is created in Wordpress, one is also created in Xenforo. When somebody logs in via Wordpress, they are also logged into Xenforo and don't have to log in again. You can use Disqus to manage your Wordpress comments and they have an option where you can link the avatar and useraccount to anything you want, in this case Xenforo. There you have it! Wordpress as a front page, Xenforo in a "community" area and comments that are integrated.

Then just style Xenforo to match your Wordpress front-end and copy the menus in or find a way to pull in the Wordpress header automatically so when you make a change, everything is in sync. But a good first step is to have an account created in Xenforo when one is created in Wordpress and log the person in across platforms.

Why no developer wants to create a Wordpress to Xenforo bridge is beyond me. The thinking is all backwards and everyone is focused on a Xenforo INTO Wordpress bridge when in fact many sites are using the Wordpress already as their homepage and simply want to add an "integrated" forum with robust software such as Xenforo.
 
Does Disqus actually work? All I ever get is "Disqus failed to load" or some nonsense.

I think the WP vs XF difference stems from a couple of things. It depends on the focus of your particular site. Ours is 99.9% forum, WP is just for the news site, and it's a kludge even as far as that goes.

If you've got some massive WP base and a forum as a sideshow, I can see how your perspective might be different.
 
We use the plugin and it works alright.

It definitely does not work. From your site, verified with FF and Chrome. This is ALL I ever get from sites that use "Disqus". If it doesn't work in stock Chrome on Win7, I don't see where it's a viable commenting option for anyone, much less a superior alternative to using the forum software to handle commenting.


crazyinjuneers.webp
 
Top Bottom