I would like to set up my Homepage to show the most recent post of certain blogs. How could I do something like that and keep it dead simple.
I would like it to look something like this.
<div 'unique-blogID'>
Title
Author/Date
teaser
read more
</div>
Any thoughts or suggestions.
thanks
Klark0
Member
Posted 15 years ago #
If it's just one blog you can use
<ul>
<?php
switch_to_blog(#INSERT BLOGID HERE#); ?>
<?php $recent = new WP_Query("showposts=5");
while($recent->have_posts()) : $recent->the_post(); ?>
<li>
#NORMAL THEME FUNCTIONS HERE LIKE the_time, the_permalink(), the_title(), the_content#
</li>
<?php endwhile ; ?>
<?php restore_current_blog();
?>
</ul>
If it's more than one blog, then modify the recent posts plugin to show to show only the blogs you want.
Thanks, I will give it a try. Will this work with multiple blogs on the same page? I would just create a new div or list with a different blog ID? And the blog ID can be found in the admin panels, correct?
thanks
Klark0
Member
Posted 15 years ago #
errr.. how many blogs you talking ? That could work, are you using a cache ?
I am not sure if I am using a cache. 5,10, maybe 20, not sure yet.
Klark0
Member
Posted 15 years ago #
Do you want to display these lists separately (per blog) or can it all be in one list ..in chronological order.
Each list will be separate, or each blog will be in its on div or list.
Thanks for the help Klarko, so far it seems to be working great.
Even simpler, the rss widget. :D
Klark0
Member
Posted 15 years ago #
Yeah that could work too. Or if you dont want to use the widget the code for that would be like this:
<?php
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('INSERT RSS FEED URL HERE');
$maxitems = 5;
$items = array_slice($rss->items, 0, $maxitems);
?>
<ul>
<?php if (empty($items)) echo '<li>No items</li>';
else
foreach ( $items as $item ) : ?>
<li><a href='<?php echo $item['link']; ?>'
title='<?php echo $item['title']; ?>'>
<?php echo $item['title']; ?>
</a></li>
<?php endforeach; ?>
</ul>
You won't have as much options though. for example generating gravatars won't be possible with this method.