Skip to content

Instantly share code, notes, and snippets.

@brianleejackson
Last active May 29, 2020 19:02
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 brianleejackson/b443f62cfdbefb9f5704820ad1a67f19 to your computer and use it in GitHub Desktop.
Save brianleejackson/b443f62cfdbefb9f5704820ad1a67f19 to your computer and use it in GitHub Desktop.
Enable custom post type WordPress preview. Source: https://woorkup.com/wordpress-custom-post-type/
//adds custom post type query var to preview links
function mycptname_cpt_previow_query_vars($link, $post) {
$custom_post_types = array('artist');
if(in_array($post->post_type, $custom_post_types)) {
return add_query_arg(['post_type' => $post->post_type], $link);
}
return $link;
}
add_filter('preview_post_link', 'mycptname_cpt_previow_query_vars', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment