Title: Create Redirection in Custom Code
Last modified: May 25, 2019

---

# Create Redirection in Custom Code

 *  Resolved [mehdi.gpr](https://wordpress.org/support/users/mehdigpr/)
 * (@mehdigpr)
 * [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/)
 * Hi,
    I want to Create a redirect with Redirection Plugin in custom code (without
   visually), Is there a Create_Redirect function in the redirection plugin?
 * How can I Create a Redirect with functions of this plugin ?
 * thanks.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/#post-11571930)
 * Please see [https://redirection.me/developer/](https://redirection.me/developer/)
 *  Thread Starter [mehdi.gpr](https://wordpress.org/support/users/mehdigpr/)
 * (@mehdigpr)
 * [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/#post-11572024)
 * thank you.
    I had seen this. But I had trouble using it. Information was not 
   enough for a beginner 🙂 I want to use php api and Red_Item::create().
 * Is it possible to show how to work with this class with an example ? What items
   will be included in Red_Item_Sanitize?
 * Thank you very much.
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/#post-11572047)
 * I don’t currently have any examples. You will need to look at the code in redirect-
   sanitizer.php and see what data is used
 *  Thread Starter [mehdi.gpr](https://wordpress.org/support/users/mehdigpr/)
 * (@mehdigpr)
 * [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/#post-11572867)
 * I Tested this :
 *     ```
       $red_arr = array(
       	'title' => 'test',
       	'group_id' => 1,
               'source' => 'https://domain.com/google',
       	'url' => 'https://google.com'
           );
       include plugin_dir_path( __DIR__ ).'Redirection/models/redirect.php';
       $redirect = new Red_Item();
       $reds = $redirect->create($red_arr);
       ```
   
 * But Not working!!!
    I’m probably having a problem in the Array structure. Alert
   message : The site is experiencing technical difficulties. Please check your 
   site admin email inbox for instructions.
 * anyone help…
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/#post-11573151)
 * As I said there is no example and you will need to figure things out from the
   code. You should call `Red_Item::create` instead of creating an object.
 * `print_r( $reds );` will show you what the problem is.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Create Redirection in Custom Code’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [John Godley](https://wordpress.org/support/users/johnny5/)
 * Last activity: [7 years ago](https://wordpress.org/support/topic/create-redirection-in-custom-code/#post-11573151)
 * Status: resolved