Show post of a category if exist. Else show post of other category
-
Hello, i have this problem:
In the index of my web i have an area which gets the first post from one category and the second post from other category
<?php $reciente = new WP_Query("cat=7&showposts=1"); while($reciente->have_posts()) : $reciente->the_post();?> <p class="newshome"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></p> <p class="fechahome"><?php the_time('j/m/Y'); ?></p> <div class="entryhome"> <?php the_excerpt(''); ?> </div> <?php endwhile; ?>
and
<?php $reciente = new WP_Query("cat=6&showposts=1"); while($reciente->have_posts()) : $reciente->the_post();?> <p class="newshome"><a>"><?php the_title(); ?></a></p> <p class="fechahome"><?php the_time('j/m/Y'); ?></p> <div class="entryhome"> <?php the_excerpt(''); ?> </div> <?php endwhile; ?>
I want to put that if there is no post on category 6 get last post of category 1. And if there is no post in category 7 get last post of category 1 but no the same post I have in the first area. I mean i have 2 posts there and if there is no post in cat 6 and 7 i want to get the last 2 post of category 1.
How can I do it?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Show post of a category if exist. Else show post of other category’ is closed to new replies.