Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Hook to redirect when single.php is loaded?

$
0
0

Replies: 0

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('http://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 all articles
Browse latest Browse all 59525

Trending Articles