# Redirect a Category Archive to a Page

> Sends visitors from a category archive to a hand-built landing page, for example /category/news/ to your Newsroom page, while posts keep their category.

- Type: PHP
- Runs: Run everywhere
- Category: [Redirects](https://wpide.com/library/category/redirects/)
- Tags: categories, redirect, landing-page
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/redirect-category-to-page/

## Code

```php
// Category slug => page path, for example 'news' => '/newsroom/'.
$wpide_category_redirects = array();

add_action( 'template_redirect', function () use ( $wpide_category_redirects ) {
    if ( ! is_category() || is_feed() ) {
        return;
    }

    $term = get_queried_object();

    if ( $term instanceof WP_Term && isset( $wpide_category_redirects[ $term->slug ] ) ) {
        wp_safe_redirect( home_url( $wpide_category_redirects[ $term->slug ] ), 301 );
        exit;
    }
} );
```

## Notes

The list is empty by default. Map category slugs to paths of pages that exist on your site.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Redirect a Category Archive to a Page" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
