WordPress.org

Ready to get started?Download WordPress

Forums

Redirecting Post to its Term (1 post)

  1. Aditya Pandey
    Member
    Posted 1 year ago #

    I am trying to redirect post to its term (in custom post type).
    I tried following in single-[post-type] "

    <?php
    $taxonomy= 'resource-list';
    $terms = get_the_terms( $post->ID, $taxonomy );
    $term_id = $terms[0]->term_id;
    $relocate = get_term_link($term_id);
    header("Location:" .$relocate);
    ?>

    But it is resulting a WP_Error.

    Can anyone point me in right direction?
    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic