.HTML POST extension for custom post type – DRAFT – PREVIEW

Here is a simple solution, if post have DRAFT status – we show a “normal” do not rewrited “URL”.

add_filter( 'post_type_link', 'custom_post_permalink' ); // for cpt post_type_link (rather than post_link)
function custom_post_permalink ( $post_link ) {
    global $post;
    $type = get_post_type( $post->ID );
    $post_status = get_post_status( $post->ID ); //get POST STATUS
    if($post_status != "draft") {
        return home_url('PUT YOUR CUSTOM POST TYPE HERE/'.$post->post_name.'.html');
    } else {
        //if POST STATUS is DRAFT
        return home_url('?post_type=PUT YOUR CUSTOM POST TYPE HERE&p='.$post->ID.'&preview=true');
    }

}

techhipbettruvabetnorabahisbahis forumuedusedusedusedueduseduseduedusedusedus