Skip to content

Instantly share code, notes, and snippets.

@Basilakis
Last active February 7, 2017 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Basilakis/4cf84968527f48abd230ba4033117262 to your computer and use it in GitHub Desktop.
Save Basilakis/4cf84968527f48abd230ba4033117262 to your computer and use it in GitHub Desktop.
Redirect log - out users from Custom Post Type Singular
function logedout_singular_redirect() {
if (!is_user_logged_in() && ( is_singular( 'job_listing' ) )
) {
// feel free to customize the following line to suit your needs
wp_redirect(site_url('my-page-slug/'));
exit;
}
}
add_action('template_redirect', 'logedout_singular_redirect');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment