Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress: Redirect from category.php to first post in category
function strytllr_redirect_from_story_to_first_slide(){
global $wp_query;
if( is_archive() && $wp_query->query('showposts=1&order=ASC') ){
// Get permalink
$post_url = get_permalink();
// Redirect to post page
wp_redirect( $post_url );
add_action('template_redirect', 'strytllr_redirect_from_story_to_first_slide');
Copy link

harshdeepkaur097 commented Sep 20, 2020

Hi, how do I implement it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment