1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HowTo: Add a link to the XenForo thread in WordPress Theme

Place a hyperlink to the XenForo thread in the post

  1. LPH
    The XenScript WordPress - XenForo bridge provides a means to integrate the two projects. Adding a link to the discussion forum in the WordPress child theme may help navigation for visitors.

    Step 1: Open content-single.php or equivalent WordPress file
    Step 2: Choose the location for the link
    Step 3: Add the following

    PHP:
    1.  
    2. <?php global $XF; echo $post->thread_id; ?>
    3.  
    Step 4: Upload the modified file.
    Step 5: Test

    There are times that WordPress posts are made without a link to XenForo, therefore, wrap the above code in an if statement.

    PHP:
    1.  
    2. <?php if( $post->thread_id != '0' ) { ?>
    3.  
    Example code:

    PHP:
    1.  
    2.     <?php if( $post->thread_id != '0' ) { ?>
    3.  
    4.        <h2 class="nav-tab-wrapper">
    5.        
    6.         <a href="#1" class="nav-tab nav-tab-active">Article</a>
    7.          
    8.         <a href="http://community.tuxreportsnetwork.com/threads/<?php global $XF; echo $post->thread_id; ?>" class="nav-tab">Discussions</a>
    9.        
    10.        </h2>
    11.      
    12.      <?php } else { global $XF;} ?>
    13.  
    Screen Shot 2013-07-23 at 8.04.47 AM.png