• I’m trying to get my single.php page to redirect to the home page if the post displayed is not in a particular category (id=19). I’ve read various things that almost do this, but I cant seem to get it to work, any help much appreciated.

    I’ve tried modifying this:

    <?php
    $category = get_the_category();
    $category_id = $category[0]->cat_ID;
    $relocate = get_category_link($category_id);
    header("Location:".$relocate);
    ?>

  • The topic ‘redirect single.php if post is not in a category’ is closed to new replies.