I'm trying to do something that I'm sure is very basic, but I can not figure out how to do it.
Here's the setup: I used the CPT UI plugin to create a custom post type called board_docs, and I used the Custom Fields plugin to create a custom field for the board_docs post type. The custom field allows you to add a file as an attachment. Once this file is added, a new permalink (post) is created. When I click on that permalink, the page is empty and only has a header and footer. How would I add an iframe (and other html content) to that page using php?
I tried using the loop, have_posts, in the functions.php file, but nothing is displaying. My code looks like this:
if ( have_posts() ) :
while ( have_posts() ) : the_post();
echo "<script>console.log('from functions.php!!!');</script>";
ob_start(); ?>
<div class="my-pdf-viewer">
<p>[iframe here]</p>
</div>
<?php ob_get_clean();
endwhile;
endif;
I tried using is_single, but still nothing:
if ( is_single(883) ) {// have_posts etc...}
The console.logs work and I see the logs printing to console for the specific posts, but that's it. I can't figure out how to display the html content.
I currently have a page called Board Docs where I display the permalinks for each post. When the user clicks on each link, it takes them to that empty page where I want to display html content. How would I do that using php?
UPDATE I found this handy resource a couple days ago and just wanted to share it with others who might be struggling with finding the right hook. https://adambrown.info/p/wp_hooks/hook
Also, hooks. I wish someone could've explained to me what these were when I first started. If you're doing any custom WordPress development, they're important to know. Happy coding.
ob_start()
for?