• 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 link to the XenForo thread in a WordPress Post

The XenScripts PHP files allow a WordPress post to be placed in the XenForo forum with a link back to the WP post. However, getting a link into the WordPress theme requires adding code to the theme. The following addition to the plugin makes this no longer necessary.

Step 1: Create a file named xf-thread-link.php

Step 2: Add the following code to the file

PHP:
<?php
/**
* Creates a link to the XenForo thread below the content in WordPress post
*/

add_filter('the_content', 'show_thread_id');

if ( !function_exists('show_thread_id') ) :

function show_thread_id($content) {
   global $XF, $wpdb;
     echo $content;
     echo '<br /><a href=" ' .  $XF->createLink($link) . 'threads/' . $XF->getThreadIdForPost($post_id) . '">Our Community</a>' ;
     echo '<hr>';
}

endif;

Step 3: Upload the file to the plugin directory. I prefer the plugin/include directory. Make note so you can include the location into the xf_integration.php file.

Step 4: Add the following code to the xf_integration.php file

PHP:
require_once( 'include/xf-thread-link.php' );
Author
LPH
Views
486
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from LPH

Top