1. Docs
  2. Add Ons
  3. Property Import
  4. Redirecting Links From Mailouts

Redirecting Links From Mailouts

Jupix

add_action('init', 'check_jupix_redirect');
function check_jupix_redirect()
{
    if ( isset($_GET['profileID']) )
    {
        $args = array(
            'post_type' => 'property',
            'meta_key'     => '_imported_ref_1491659041', // CHANGE '1491659041' TO BE ID OF IMPORT
            'meta_value'   => $_GET['profileID']
        );
        $my_query = new WP_Query( $args );

        if ( $my_query->have_posts() )
        {
            while ( $my_query->have_posts() )
            {
                $my_query->the_post();

                header("HTTP/1.1 301 Moved Permanently");
                header("Location: " . get_permalink(get_the_ID()));

                exit();
            }

        }
        wp_reset_postdata();
    }
}

ReapIT / JET

add_action('init', 'check_jet_reapit_redirect');
function check_jet_reapit_redirect()
{
    if ( isset($_GET['pid']) )
    {
        $args = array(
            'post_type' => 'property',
            'meta_query' => array(
                array(
                    'key' => '_imported_ref_1491659041',  // CHANGE '1491659041' TO BE ID OF IMPORT
                    'value' => $_GET['pid'],
                    'compare' => 'LIKE'
                )
            )
        );
        $my_query = new WP_Query( $args );

        if ( $my_query->have_posts() )
        {
            while ( $my_query->have_posts() )
            {
                $my_query->the_post();

                header("HTTP/1.1 301 Moved Permanently");
                header("Location: " . get_permalink(get_the_ID()));

                exit();
            }

        }
        wp_reset_postdata();
    }
}
Was this article helpful to you? Yes No