[resolved] Redirect Issue (3 posts)

  1. swayam.tejwani
    Posted 3 years ago #

    Hello Everyone,

    I am creating a simple plugin which use to redirect to url which you can define in edit page under custom field named 'redirect' , then when you view that page this will redirect to that url which you have defined in custom field, here is my code `
    function custom_redirect () {
    global $post;
    if ( is_page() || is_object( $post ) ) {
    if ( $redirect = get_post_meta($post->ID, 'redirect', true ) ) {

    wp_redirect( $redirect );
    add_action( 'get_header', 'custom_redirect' );`
    now when i add a url then when i see it takes me to the url something like this http://localhost/wordpress/www.google.com, i can't figure it out why its not redirecting to google.com...does anyone help me out with this..

  2. Timothy Jacobs
    Posted 3 years ago #

    Your url needs to be prefixed with http://

  3. swayam.tejwani
    Posted 3 years ago #

    Oh Thanks..Silly Question Again...

Topic Closed

This topic has been closed to new replies.

About this Topic