Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enable custom post type WordPress preview
//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
You can’t perform that action at this time.