add_rewrite_rule and how to get the custom post into the worpress loop the correct way

The problem is that when the main query is parsed, having just a custom query var set will not result in a successful main query, so it defaults to setting up the home page blog posts query.

To solve this, set the post type query var directly in the rewrite rule and there’s no need for those intermediate steps-

add_rewrite_rule('slp\/(.*)', 'index.php?speaker=$matches[1]', 'top');

You will also need to filter post_type_link if you want to hide the original URL when permalinks are output by API functions.

function wpd_speaker_links( $url, $post ){
    if ( 'speaker' == get_post_type( $post ) ) {
        return home_url( "/slp/" . $post->post_name . "https://wordpress.stackexchange.com/"  );
    }
    return $url;
}
add_filter( 'post_type_link', 'wpd_speaker_links', 10, 2 );

error code: 523