- Compatible XenWord Versions
- 3.x
- Compatible WP Versions
-
- 4.1
- 4.2
- Compatible XF Versions
-
- 1.4
- Visible Branding
- No
A simple XenForo addon called XenLate is now available for download and installation.
DIY Instructions:
WPPosts.php
Callback
CSS
DIY Instructions:
- Create a file called WPPosts.php.
- Copy and paste the code below into the file.
- Change the class to the directory structure you would like
- If you keep the class as TRN_XenWord_Model then you must create the directories under the XenForo/library
- Change the path to wp-blog-header.php
- Modify the numberposts to meet your desires
- Save and Upload the file
- Go to XenForo admin panel templates
- Find the template ad_sidebar_below_visitor_panel
- Add the callback, adjust the path to the WPPosts file
- Add CSS to the EXTRA.css template in XenForo Style
WPPosts.php
PHP:
<?php
/**
* Filename: WPPosts.php
* Author: LPH
*/
class TRN_XenWord_Model_WPPosts extends XenForo_Model {
public static function getHtml() {
define( 'WP_USE_THEMES', false );
define( 'DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT'] );
// Change the path to the correct location
require( DOCUMENT_ROOT . '/wp-blog-header.php' );
$args = array( 'numberposts' => '5', 'post_type' => 'post', 'post_status' => 'publish' );
$LatestWPPosts = wp_get_recent_posts( $args );
echo '<div class="section">
<div class="secondaryContent">
<div class="visitorText">
<h3>Latest Blog Posts</h3>
<div class="LatestWPPosts">';
foreach ( $LatestWPPosts as $LatestWPPost ) {
$excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $LatestWPPost['ID']));
$thumbnail = get_the_post_thumbnail( $LatestWPPost['ID'], array( 50, 50) );
if ( empty( $thumbnail ) ) {
echo "<h4><a href='" . esc_url( get_permalink( $LatestWPPost['ID'] ) ) . "'>" . $LatestWPPost['post_title'] . '</a></h4>';
} else {
echo '<div class="recent_post">';
echo '<div class="thumbnail">' . $thumbnail . '</div>';
echo "<h4><a href='" . esc_url( get_permalink( $LatestWPPost['ID'] ) ) . "'>" . $LatestWPPost['post_title'] . '</a></h4><br />';
echo '<div class="excerpt">' . $excerpt . '</div>';
echo '</div>';
}
}
echo '</div>
</div>
</div>
</div>
';
}
}
// End WPPosts.php
Callback
Code:
<xen:callback class="TRN_XenWord_Model_WPPosts" method="getHtml"></xen:callback>
CSS
Code:
div.recent_post {
position: relative;
padding-bottom: 25px;
margin-top: 5px;
}
div.thumbnail {
float: left;
margin-right: 1em;
margin-top: 2px;
}
div.excerpt {
padding-bottom: 1em;
padding-left: 5em;
border-bottom: 1px solid grey;
}