WP Discourse - Template Customization

hi simon

thanks for responding. appreciate the help immensely.

but it doesnt seem to work

the output was

<small>Originally published at http://staging.a1.sg/matrix/</small><br><br><iframe title="GCE O-Level 
A-Maths: Matrix &amp; its Inverse" width="525" height="394" 
src="https://www.youtube.com/embed/alJEZwwtQ3U?feature=oembed" frameborder="0" 
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>. 
</iframe><br><p><iframe title="GCE O-Level A-Maths: Matrix &amp; its Inverse" width="525" 
height="394" src="https://www.youtube.com/embed/alJEZwwtQ3U?feature=oembed" frameborder="0" 
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>. 
</iframe></p>

i also added an extra code in the functions.php file after trying out the above proposed solution to ensure the youtube link stays as a string.

remove_shortcode( 'embed' );
remove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'autoembed' ], 8 );
remove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'run_shortcode' ], 8 );
remove_action( 'edit_form_advanced', [ $GLOBALS['wp_embed'], 'maybe_run_ajax_cache' ] );

but the output (as shown below) has < p > tags too. as mentioned earlier, the < p > tags in a discourse posts are causing the issue.

<small>Originally published at http://staging.a1.sg/matrix/</small><br><br>. 
<p>https://www.youtube.com/watch?v=alJEZwwtQ3U</p>

i.e. if i remove the p tags, the link will autoembed on discourse. but it’s still a manual process.