[resolved] get only the latest post from all my network site (3 posts)

  1. sugarFornaciari
    Posted 4 years ago #

    Hi Guys,
    I am here to ask some help in order to succeed in this development.

    I am trying to get only the most recent article from all the articles I have on the netword. I wish use code. No plugin and at the moment what I have done it is publish the latest post from each blog.

    In other word I need help just to select and publish the article most recent from a list of recent articles.

    Here the code

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. sugarFornaciari
    Posted 4 years ago #

    Inside the function there is comment:
    // here I have the recent post for each blog

    This is the place where it is possible get the recent post from each blog.
    So My idea is that I could store this data and order by most recent data.

    Could anyone help?

  3. sugarFornaciari
    Posted 4 years ago #

    Hi Guys I have solved...
    Ok having the list of recent articles of all the network that you may build yourself by reading here

    and here

    you can put every thing in an array and after that sorting dates with this function that give the most recent date

    $mostRecent= 0;
    	$date_c =0;
    	$post_c =0;
    	foreach($post_date_ar as $date){
    	  $curDate = strtotime($date);
    	  if ($curDate > $mostRecent) {
    		 $mostRecent = $curDate;
    			$post_c = $c;

    and after that, i will use this info to get the item from the list of post

    $recent_post_c = 0;
    	foreach($recent_post_ar as $post) : setup_postdata($post);
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    		<hr />

    The code is not very elegant but it works...

Topic Closed

This topic has been closed to new replies.

About this Topic