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 🙂
Related Posts:
- Creating an Image-Centric Custom Post Type?
- Submit post and upload image from front-end
- Correctly delete posts with meta and attachments [duplicate]
- Attaching media to custom posts without editor
- get attachments for all posts of particular post type
- List most recent image uploads, but only for specific custom post type
- wp_generate_attachment_metadata gives me an empty array
- Add custom field to media attachment image attribute in post editor
- Count all images of a certain post type
- How do you modify the ‘post_parent’ of a custom post type?
- Stopping WordPress from Auto Generating Image Files for Sizes
- Do attachments added to custom post types have a post parent?
- Return Attachments from Custom Post Type
- How to get attached file in wordpress from custom post
- Impossible to get Attachments Outside WordPress?
- Issue to get wp_get_attachment_image with cmb2
- Custom Post Type – List all attachments on Edit Screen
- Disable featured image
- get_attached_media() on author page not working
- Why can’t my admin account manage attachments on a custom post type with a unique capability type?
- How can I get the number of custom post type posts that have a specific attachment image set?
- Hierarchy and access control for Custom Post Types (CPT)
- Searching Custom Post Types
- How to import files to individual posts of a custom type
- How do you get the full size url of an attachment image
- Add post meta programmatically to attachment
- Show list of custom posts with respective attachments?
- Let users upload image(s) to the post from front end
- How do I add multiple post types to this query?
- Why doesnt my tag page populate with this custom post type?
- How to add a default predefined thumbnail when creating a brand new post?
- Custom attachment function not working in v5.4.2?
- Issue on Getting URL of Uploaded Image to a Custom Post Type
- Dupplication of Custom Post Type while adding attachment
- Update Cateogory Taxonomy Count for Attachment Post Type
- Delete custom post type metadata without deleting the post in admin area
- Delete attachment with post
- Display custom post type attached media file sizes
- get_post_meta is not working inside shortcode
- False Positive on has_post_thumbnail
- Sort a custom post with ACF: Date Picker & Display Featured!
- detect when a custom post is cretaed for the first time
- Custom post type, have only my meta boxes
- Custom Taxonomy not displaying all post
- Exclude current post for custom post type
- detect your custom post type in WordPress
- Add categories to a page with out using Custom Post Types
- How to limit post per page of custom post type?
- How to get all Custom Post Type Filtered by one Specific Taxonomy Term
- How to customize work area / admin area in a custom post type without plugins?
- Custom posts template page
- Display posts with tag for custom post type only
- Display Repeatable Meta Box Content
- How can i automatically add CPT single pages as sub menu items
- If there is only one post (show elements) else (show other elements)
- Conditional for post type inside loop (recent posts)
- Using wp_query to modify the loop in index.php for a CPT
- A Collection of Custom Post Types Displayed In a Submenu
- Category archive in with conjunction with custom post type is empty
- writing posts in indian regional language (Punjabi)
- Set thumbnail and title for a post type archive (not post itself!)
- the_post() is printing titles in page footer
- Use remove_meta_box conditionally on custom post type
- create custom meta box with default value
- Different slug taxonomy for two different CPT
- Can I restrict category availability?
- New “Custom Types” item in admin menu. Is this a plugin or a new wordpress feature?
- Custom columns doesn’t appear in custom post type
- Create an archive page for custom post type with custom taxonomy
- ACF in wordpress
- WP_Query Custom Post Type if Category ID Equals
- Programatically inserted posts not showing in Posts Table
- Theme independent plugin by using default page template
- Can’t use pagination with custom taxonomy
- Why does accessing url by category cause issues with post types?
- Custom Post Type Category On Admin
- Option page’s form doesn’t work
- Hide specific taxonomies from a taxonomy list using ‘get_object_taxonomies’
- How does the ‘the_post_navigation()’ work for CPT’s?
- Add arguments to get_the_terms for custom post types
- Custom User role not working with custom post type
- Display post from a date range from custom field
- Is it safe to change a Custom Post Type from “hierarchical:false” to “hierarchical:true”?
- How to set up Custom Post Type archive page as Front page
- Display custom post using ID
- Url to archive page for custom post type
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- retrieve permalinks of posts inside custom post type by using post ID
- admin-ajax.php GET custom-post titles
- Custom Permalinks with meta value not working. Why?
- Create metaboxes based on custom post type
- How can I use this code on a custom database table?
- Custom URLs in post types make it impossible to view archive
- Editor / Add Media: Is it possible to only allow galleries?
- Custom post types and ‘new WP_Query’
- Can I change my post type to anything and my site still work?
- custom post type and custom taxonomy
- Custom post type as child of page
- Query Custom Post Types with checkboxes
- How to add and clear custom post types and taxonomies in a plugin? Considerations for existing data