Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is possible to redirect category to first available child post please? Thanks!

share|improve this question

1 Answer 1

I had to do that, but only in some categories in my site. This was the code I used:

 if (is_category('3') ||  is_category('5') ) {
 $category = get_the_category();
 $posts =  query_posts('showposts=1&cat='.$category[0]->cat_ID);
 if(have_posts()) :
    wp_redirect(get_permalink($post->ID));
endif;
}

Of course, if you need to do it in all your categories, you can remove the condition.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.