Reputation: 694
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
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
Reputation: 628
wp_redirect
is just fine
if(is_archive()){
wp_redirect($location);
}
Upvotes: 1
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