Powered By Blogger

Tuesday, September 27, 2016

wordpress get latest post from another website

1.Using Template
2. RSS widget


https://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog

plugin:

https://wordpress.org/plugins/featured-images-for-rss-feeds/screenshots/

https://wordpress.org/plugins/wp-rss-aggregator/screenshots/



<?php
/**
 * Template Name: Blog  Page
 *
 * A Fully Operational maintenance Page
 *  WordPress
 */

get_header(); ?>
<div class="content_bgr website-maintenance-plan websiteplan-plan">
<div class="full_container_page_title">
<div class="container startNow">
<div class="row no_bm">
<?php
//replace with your URL
$rss = fetch_feed("http://demoinfolink.com/blog/");

if (!is_wp_error($rss)) :

$maxitems = $rss -> get_item_quantity(5); //gets latest 5 items This can be changed to suit your requirements
$rss_items = $rss -> get_items(0, $maxitems);
endif;

//grabs our post thumbnail image
function get_first_image_url($html) {
if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) {
return $matches[1];
}
}

//shortens description
function shorten($string, $length) {
$suffix = '&hellip;';
$short_desc = trim(str_replace(array("\r", "\n", "\t"), ' ', strip_tags($string)));
$desc = trim(substr($short_desc, 0, $length));
$lastchar = substr($desc, -1, 1);
if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?')
$suffix = '';
$desc .= $suffix;
return $desc;
}
?>
<!--start of displaying our feeds-->
<ul class="rss-items" id="wow-feed">
<?php
if ($maxitems == 0) echo '<li>No items.</li>';
else foreach ( $rss_items as $item ) :
?>
<li class="item">
<span class="rss-image">
<?php echo '<img width="200" src="' . get_first_image_url($item -> get_content()) . '"/>'; ?>
</span>
<span class="data">
<h5><a href='<?php echo esc_url($item -> get_permalink()); ?>' title='<?php echo esc_html($item -> get_title()); ?>'> <?php echo esc_html($item -> get_title()); ?></a></h5>
<span class="date-image">&nbsp;</span>
<small><?php echo $item -> get_date('F Y'); ?></small><!--This can be changed -->
<span class="comment-image">&nbsp;</spa






































































n>







































































<small><?php $comments = $item -> get_item_tags('http://purl.org/rss/1.0/modules/slash/', 'comments'); ?><?php $number = $comments[0]['data']; ?>
<?php //checks and displays comment count
if ($number == '1')
{
echo $number . "&nbsp;" . "Comment";
}
else


























































{


























































echo $number . "&nbsp;" . "Comments";
}
?>
</small>
<p><?php echo shorten($item -> get_description(), '150'); ?></p>
</span>






































</li>






































<?php endforeach; ?>
</ul>

</div>
</div>
</div>
</div>

<?php get_footer(); ?>








add the following to your theme’sfunctions.php

Whilst functions.php is open check for or add the following

No comments:

Post a Comment