I am trying to redirect the category link to the first child post. I am using following code in category.php
. This redirects, but link doesn't go to first child post. How can I redirect to the first child post, in ASC order by date?
/*
Category Template:
Template URI:
Description:
*/
if ( have_posts() ) :
while ( have_posts() ) : the_post();
wp_redirect( get_permalink( $post->ID ) );
endwhile;
endif;