Please add this code when you want to
show blog
<?php
include_once(ABSPATH
. WPINC . '/feed.php');
include_once(ABSPATH
. WPINC . '/SimplePie.php');
$rss =
fetch_feed('/category/blog/feed/');
// Add your Url which you want to pull over blog
if (!is_wp_error( $rss ) ) :
$maxitems =
$rss->get_item_quantity(5);
$rss_items = $rss->get_items(0,
$maxitems);
endif;
?>
<?php
function
get_first_image_url($html)
{
if
(preg_match('/<img.+?src="(.+?)"/', $html, $matches))
{
return $matches[1];
}
}
?>
<?php
function shorten($string, $length)
{
$suffix = '…';
$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;
}
?>
<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
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"> </span><small><?php
echo $item->get_date('F Y'); ?> </small>
<span
class="comment-image"> </span><small><?php
$comments =
$item->get_item_tags('http://purl.org/rss/1.0/modules/slash/',
'comments');?><?php $number = $comments[0]['data']; ?>
<?php if ($number ==
'1'){ echo $number." ". "Comment"; }
else {echo $number. " "."Comments";}?></small>
<p><?php echo
shorten($item-> get_description(),'150');?></p>
</span>
</li>
<?php endforeach; ?>
</ul>
No comments:
Post a Comment
Thanks for visit blog.