• Resolved antonemery

    (@antonemery)


    I am working on a headless WordPress and trying to redirect to a custom front end preview after single.php is loaded. This would take place when the user clicks the Preview button when writing a post. It currently works when I modify single.php directly, but ideally I would like to place all this code in a plugin.

    my-plugin-php

    add_action('template_redirect', 'single_page_action', 9);
    
    function single_page_action() {
        wp_redirect('https://www.example.com/custom-post-preview');
        die();
    }

    As far as I can tell so far my single_page_action function is not being called at all. Does anyone know of any hook I can use when the preview for a post is loaded? Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hook to redirect when single.php is loaded?’ is closed to new replies.