I’m trying to make a loop that will get the latest 25 posts from one category and the latest 55 from another, they need to be in the same loop and the posts are in a isotope filtering system and when it is on ‘all’ it needs to display all the categories in date order not category type>post date, is there a trick for doing this?
Thanks, Harry.
EDIT:
Here is what I currently have for my get_posts loop;
<?php
global $post;
$myposts = get_posts('cat=10,11,49&numberposts=50');
foreach($myposts as $post) :
setup_postdata($post);
$cat_name = '';
$category = get_the_category();
$cat_name = $category[0]->slug;
?>
<?php endforeach; ?>
I have tried a few logical things such as;
$myposts = get_posts('cat=10,49&numberposts=50', 'cat=11&numberposts=50');
But this just returned posts from category 10 and 49.
I thought maybe something like this could work but need the right syntax for it;
$myposts11 = get_posts('cat=11&numberposts=50');
$myposts1049 = get_posts('cat=10,49&numberposts=50');
$myposts = $myposts1049 + $myposts11;
The issue with what you’ve tried is you’ve added two post arrays together as if they were numbers;
You should be using
array_merge
to merge the two arrays into a single array and loop through that instead;EDIT
Looking at the WordPress StackExchange site, Otto has answered a very similar question here;
https://wordpress.stackexchange.com/questions/130009/how-to-merge-two-queries-together#answer-130055
And additionally used
array_unique
to eliminate duplicates before using the new array in aWP_Query
object.