Last active
December 15, 2015 19:59
-
-
Save jennschiffer/5315205 to your computer and use it in GitHub Desktop.
printing 5 latest comments of baristanet & baristakids sites in time-descending order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// bnet comments | |
$commentsBNET = get_comments('number=5&status=approve'); | |
// bkids comments | |
switch_to_blog( '3' ); | |
$commentsBKIDS = get_comments('number=5&status=approve'); | |
restore_current_blog(); | |
// merge comments | |
$comments = array_merge($commentsBNET, $commentsBKIDS); | |
// sort comments | |
foreach ($comments as $comm) { | |
$sortKeys[] = $comm->comment_date; | |
} | |
array_multisort($sortKeys,SORT_DESC,$comments); | |
// splice comments array to set number | |
array_splice($comments, 5); | |
// print comments | |
foreach($comments as $comm) : | |
$class = "comment-bnet"; | |
if ( !get_the_title($comm->comment_post_ID) ) { | |
switch_to_blog( '3' ); | |
$class = "comment-bkids"; | |
} | |
$url = '<a href="'. get_permalink($comm->comment_post_ID).'#comment-'.$comm->comment_ID .'" title="'.$comm->comment_author .' on '.get_the_title($comm->comment_post_ID).'">' . $comm->comment_author . ' on '.get_the_title($comm->comment_post_ID) . '</a>'; | |
echo '<li class="' . $class . '">' . $url . '</li>'; | |
restore_current_blog(); | |
endforeach; | |
?> |
ALL CAPS LOCK COMMENTING ON GISTS
This works like shit because sometimes two of the blogs have a post with the same ID and show it will not detect the lack of title in a post outside of the current blog blargh blaasodjfosaijrowejrsdfjdsfjggggg.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THERE HAS GOT TO BE A BETTER WAY TO DO THIS