1.Using
Template
2. RSS widget
https://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog
plugin:
h
ttps://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 = '…';
$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"> </span>
<small><?php echo $item -> get
_date('F Y');
?></small><!--This can be ch
anged -->
<span class="comment-image"> </spa
n>
<small><?php $comments = $item -> get_item_tags('http://purl.org/rss/1.0/modules/slash/', 'comme
nts'); ?><?php $number = $
comments[0]['data']; ?>
<?php //checks and displays comment count
if ($number == '1')
{
ec
ho $number . " " . "Comment";
}
else
{
echo $number . " " . "Comments";
}
?>
</small>
<
p><?php echo shorten($ite
m -> get_description(), '1
50'); ?></p>
</s
pan>
</li>
<?php e
ndforeac
h; ?>
</ul>
</d
iv>
<
/div>
</div>
</d
iv>
<?
php get_footer(); ?>
add the following to your theme’sfunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<?php
//add post thumbnails to RSS images
function cwc_rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_excerpt();
}
return $content;
}
add_filter('the_excerpt_rss', 'cwc_rss_post_thumbnail');
add_filter('the_content_feed', 'cwc_rss_post_thumbnail');
?>
|
Whilst functions.php is open check for or add the following
|
add_theme_support( 'post-thumbnails' );
|
No comments:
Post a Comment