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
- Nested custom post types with permalinks
- wp_dropdown_categories in custom post type with custom taxonomy
- Filtering a WP Query result
- Resource Issues: Importing external data into custom post type and keeping records up to date
- How to make a page template to list all galleries?
- Define menu_order on Creation of New Custom Post?
- Unable to get post content from custom post type loop
- Should I use custom taxonomy or custom post type
- Custom Post Type doesn’t show Draft and Trash Options
- How to query_post custom posts within default taxonomy?
- Static apple-app-site-association file with wordpress
- Is it possible to have a custom post type with feed but without the archive?
- Custom bulk_action
- Add parent post to Custom Post Type [closed]
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- What’s the name of the custom post type yearly archive template?
- Adding Multiple Post Types to Query [duplicate]
- Allow contributor to edit own posts after published, without plugin
- Custom post type in Custom widget – $listItem
- Get all metadata for a given custom post type
- Change search query in wordpress custom post type
- CPT requires manage_options and edit_posts for some reason
- Updating a custom post status after an expiry date rather than trashing it
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Custom Post Type / Taxonomy / Term – what template to use to avoid 404-page?
- How to get post detail based on URL of the post
- Display relationship between posts
- Event Manager: Events Deleted are still in DB as published but hidden in admin
- WordPress custom post type rewrite rule matches all pages returning 404
- Issue on Counting CPT’s Under Taxonomy Term
- Adding multiple real estate properties to back end
- Manage theme related custom posts
- WP_Query wooCommerce category
- Multiple posts selection [closed]
- How to make a non-public post on wordpress approval?
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- Filter page ID outside the loop and order
- the_post_navigation in single page with multiple taxonomies
- Url rewrite with custom post type and taxonomy
- wordpress category form fields in popup
- How can I show posts with the same tag?
- How Do I Add a Custom Post Type URL to Content?
- Paginate yearly archives for a custom post type
- Custom taxonomy meta fields
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- is therer any wordpress function to retrieve a specific html element from post content
- How to rewrite custom slugs that follow my rules
- Problem with shortcode
- display related posts based on the PAGE TITLE
- Custom Post Types Permalink
- What is the best way to relate different custom post types?
- Custom Sort Order for Custom Post Type Taxonomy
- Load posts via AJAX without draft status
- How to add categories to a custom post type using wp_insert_post($new_post);
- Modify permalink of CPT archive to support two taxonomies
- Why does wp_generate_uuid4() timeout?
- Delete Term from Custom Taxonomy using wp_delete_term isn’t working
- WP Query – Can’t get posts with specific taxonomy
- Allow child pages with the same base as the CPT slug
- upload image with rest API to the media library
- WordPress post objects in one parent post object
- Custom Post Type slug has the same Redirection entry