How do I add html content to custom post type Posts using php?

After searching through the wordpress docs, I found what I needed. What I was missing was the hook called “the_content”. My function, and all the code I wrote inside it, was correct. I just needed this stupid hook.

function displayIframe($content) {
  //[my code to get the $currentPostID and $currentPostGuid]

  //...
  //...

  if (is_single( $currentPostID )) {// if on the specific custom post page
    $content .= "<iframe src="" . esc_html($currentPostGuid)  . "" width=100% height=900></iframe>";
  }

  return $content;
}

function main() {
  // the_content hook was what I needed; I had no idea it existed
  add_filter("the_content", __NAMESPACE__ . "\displayIframe");
}

I hope this is helpful for others. Goodluck 🙂