Steven Jones
Steven Jones

Reputation: 694

Redirect in WordPress

Using Wordpress, I would like to redirect to a certain page on the site if the user visits an archive is_archive().

How would I go about this? Could I add something to functions.php?

Upvotes: 1

Views: 302

Answers (4)

user894932
user894932

Reputation:

In your archive.php template file, put an if statement at the top with the header location redirect if the criteria for redirection is met, perhaps using is_page(); by the sounds of it.

Or if it is a certain page, you could do something in .htaccess.

Upvotes: 0

Gaurav
Gaurav

Reputation: 628

wp_redirect is just fine

if(is_archive()){
    wp_redirect($location);
}

Upvotes: 1

The Alpha
The Alpha

Reputation: 146191

Using WordPress hook in functions.php, just paste this snippet in your functions.php

function redirect_to_url(){
    if(is_archive()){
        $url='your redirect url url';
        wp_redirect( $url );
    }  

}
add_action('template_redirect', 'redirect_to_url');

There is an article here, it may help you.

Upvotes: 1

madeye
madeye

Reputation: 1406

<?php
    wp_redirect($location);
    exit;
?>

Upvotes: 0

Related Questions