WordPress.org

Support

Support » Plugins and Hacks » Quick Page/Post Redirect Plugin » [Resolved] Use redirect in wp_insert_post function

[Resolved] Use redirect in wp_insert_post function

Viewing 1 replies (of 1 total)
  • syntaxlb,
    You can add a redirect by adding meta data to the post after you insert it. You need to assign a variable to your wp_insert_post call, and then you can add the meta, like so:

    //do your insert like normal
    $the_new_post = wp_insert_post($your_post_args);
    //then check it and add meta data
    if($the_new_post !== false){
      add_post_meta($the_new_post, '_pprredirect_active', '1', true);
      add_post_meta($the_new_post, '_pprredirect_url', 'http://redirect.url/here/', true);
      add_post_meta($the_new_post, '_pprredirect_type', '301', true);
    }

    Other meta items available are:
    _pprredirect_newwindow where the value can be 1 or 0
    _pprredirect_relnofollow where the value can be 1 or 0
    _pprredirect_rewritelink where the value can be 1 or 0

    The _pprredirect_type can be 301, 302, 307 or meta.

    Hope this helps.
    Regards,
    Don

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Use redirect in wp_insert_post function’ is closed to new replies.
Skip to toolbar