Last active
September 20, 2020 20:28
-
-
Save cutterkom/8baed06ed2295d8b8078 to your computer and use it in GitHub Desktop.
WordPress: Redirect from category.php to first post in category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function strytllr_redirect_from_story_to_first_slide(){ | |
global $wp_query; | |
if( is_archive() && $wp_query->query('showposts=1&order=ASC') ){ | |
the_post(); | |
// 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'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how do I implement it?