leclaeli
Member
Posted 8 months ago #
I have a portfolio website with several categories and the portfolio page shows all of the posts in order of date. However, I would like to display the most recent post from each category first and then have all the rest display after. Here is the code from the portfolio template page.
<?php include_once (TEMPLATEPATH . '/title.php');?>
<?php $values = get_post_custom_values("category-include"); $cat=$values[0]; ?>
<?php global $more; $more = 0;?>
<?php $wp_query = new WP_Query(); ?>
<?php $catinclude = 'portfoliocat='. $cat ;?>
<?php $wp_query->query("post_type=portfolio" . '&' . $catinclude .' &paged='.$paged.'&posts_per_page=-1'); ?>
<?php get_template_part( 'loop', 'portfolio' );?>
dadvan
Member
Posted 8 months ago #
try this:
<?php include_once (TEMPLATEPATH . '/title.php');?>
<?php $values = get_post_custom_values("category-include"); $cat=$values[0]; ?>
<?php global $more; $more = 0;?>
<?php $wp_query = new WP_Query(); ?>
<?php $catinclude = 'portfoliocat='. $cat ;?>
<?php $wp_query->query("post_type=portfolio" . '&' . $catinclude .' &paged='.$paged.'&posts_per_page=-1&orderby=date&order=DESC'); ?>
<?php get_template_part( 'loop', 'portfolio' );?>
leclaeli
Member
Posted 8 months ago #
Thanks for the reply, but that's exactly what is happening already. The issue is that if the last few posts are from the same category, all those posts show up first. I just want the last one from each category to appear first.
Example here
As you can see there are all "Trailers" at the the top of the page because those were most recently posted. I'd like the other categories (vehicles, semi-trucks, emergency, etc...) to have a spot at the top as well.
dadvan
Member
Posted 8 months ago #
OK, I see. So you want the the newest/most recent post from each category to show first but do you have 30+ categories? If not, whats to happen after you show the newest category or do you just want to show the newest from each category and then end it from there?
leclaeli
Member
Posted 8 months ago #
Yes, that's what I want and no I don't have 30+ categories. I'd like the rest of the posts to fill the rest of the page. What's the significance of 30?
Thanks!