• HI,
    i have create a redir.php and placed in the home directory to do the redirect. I want to pass in the post id and then retrieve a custom field value of the post and feed to header(‘location:’.$url);

    this is what I have, but it’s not working. It gives me “Parse error: parse error in \redir.php on line 5”

    <?php
    
    require('./wp-blog-header.php');
        echo $id = $_GET['id'];
    	 echo $yes_price = get_field('deal_http_link',post->$id);
        /* header('Location:'.$id);*/
    ?>

Viewing 1 replies (of 1 total)
  • Create this redir.php page as redirection template, to do this make the following changes:

    <?php
    /**
     * The template for redirecting page.
     * Template Name: Redirection
     */
    
    global $post;
    //Get custom field value
    $redirect_url = get_post_meta($post->ID,'custom_field_name',true);
    wp_redirect($redirect_url);
    exit;
    ?>

    Now If you want to redirect any page then assign this template to that page with redirection url as custom field.

Viewing 1 replies (of 1 total)
  • The topic ‘how to retrieve custom field at root directory?’ is closed to new replies.