Enable custom post type WordPress preview. Source: https://woorkup.com/wordpress-custom-post-type/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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