Skip to content

Instantly share code, notes, and snippets.

@nathanaelphilip
Created August 15, 2014 21:30
Show Gist options
  • Save nathanaelphilip/f5f327f7f77b6543f47b to your computer and use it in GitHub Desktop.
Save nathanaelphilip/f5f327f7f77b6543f47b to your computer and use it in GitHub Desktop.
global $wp_query;
$news = new wp_query(array('post_type' => 'news','nopaging' => true));
$psts = $wp_query->posts;
$nws = $news->posts;
$pstsnumber = count($psts);
$newsnumber = count($nws);
$break = $pstsnumber/$newsnumber;
$current = 0;
$nwskey = 0;
echo $nwskey;
echo $newsnumber;
foreach ($psts as $key => $p) {
#echo $current;
if ( ($break == $current) && ($nwskey < $newsnumber) ) {
echo $key."<br>";
#$psts[] = $nws[$nwskey];
$current = 0;
}
#$psts[] = $p;
$nwskey++;
$current++;
}
#print_r($psts);
$wp_query->found_posts = $wp_query->found_posts + $pstsnumber;
$wp_query->posts = $psts;
#$wp_query = $news;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment