Create a Redirect
wp_create_redirectCreate 301/302/307/308 redirects in the Redirection plugin to keep old URLs working after slug changes, preserving search authority.
Instructions
Create a 301 (or 302/307/308) redirect in the Redirection plugin. Use after any slug change or page re-parenting so the old URL keeps working and search authority transfers.
Requires the Redirection plugin to be active and admin rights.
Args:
source (string): Old path to redirect FROM, e.g. '/listen/current-season/'. Required.
target (string): Path or URL to redirect TO, e.g. '/concerts/this-season/'. Required.
code (301|302|307|308): Default 301 (permanent).
title (string): Optional note shown in the admin list.
group_id (number): Redirection group. Default 1.
regex (boolean): Treat source as a regex. Default false.
response_format (enum): markdown | json.
Returns: the created redirect.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | HTTP status. 301 = permanent (default; passes SEO authority). 302/307 = temporary. | |
| regex | No | Treat source as a regular expression. Default false. | |
| title | No | Optional note shown in the Redirection admin list. | |
| source | Yes | Old path to redirect FROM. Root-relative with a leading slash, e.g. '/listen/current-season/'. | |
| target | Yes | Path or full URL to redirect TO, e.g. '/concerts/this-season/'. | |
| group_id | No | Redirection group ID. 1 = the default 'Redirections' group. | |
| response_format | No | Output format: 'markdown' for human-readable, 'json' for machine-readable. | markdown |