I don’t know any other way
There is a much, much better way to do this – custom fields.
As per these instructions in the custom fields docs, let’s say you use the field name iframe_url
:
<iframe src="https://wordpress.stackexchange.com/questions/230707/<?php echo esc_url( get_post_meta( $post->ID,"iframe_url', true ) ?>" width="960" height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<?php the_content() ?>
See how much cleaner that is? You’ve separated data from content; no nasty regular expressions or string hacking.
Related Posts:
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- Display a query with multiple post types and same relationship on a single page
- Custom post status not working
- Date archives for custom post type
- How can I add dropdown widget/box to admin post page?
- Custom post type loops with different page templates
- Limit Authors to their Own Posts on front-end excluding admins
- Append taxonomy terms as class names in markup?
- How do you output custom code between posts in the loop?
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Output custom post shortcode. Help spot the error.
- GravityForm: Populate Dropdown with custom post type [closed]
- Loading all files within a directory
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Add custom column in custom post type edit page
- What’s the difference between same wp functions get_posts(); functions in different form?
- How to customize a permalink (URL) structure?
- Can I list a custom post type within another custom post type in the admin area?
- Set URL link to featured image of custom post type
- AJAX load more for different custom post type loops
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- get_post_meta not working on publishing
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- ACF field key/value to show on taxonomy list
- Hide a widget inside a div on specific type of post
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Different Category system needed for the Custom Post Type
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- categories should be available across all custom post types
- PHP question: how to combine syntax?
- Loop increase number
- custom post for slider
- Assign category a default post type
- Add an Outside Wrapper to my Header and Make it Full Width
- How to use a variable as a function name?
- How exclude or skip post type with get_next_post_link
- Create short URL with auto 301 redirect
- providing access to post_id or post inside functions.php
- Removing full title and breadcrumb header container for a specific post type
- Is it possible to use array_walk() to append terms to an array of posts?
- Show current user posts in custom post type query
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- post_content is stripping HTML when adding a new post? [closed]
- Using Wp_Query, Json to add Highcharts series data
- Template code to split a post and print a custom field?
- Let users upload image(s) to the post from front end
- Foreach loop returning more than one item when querying taxonomy
- Function to erase every post from a taxonomy
- Post type Echo code is repeating on homepage
- redirect after submiting post for review
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- set object terms after some some time of published post – functions.php
- php dynamic content inside shortcode
- update custom taxonomy custom fields
- Check that a slug is present in the get_terms request
- Pagination not working in custom post type. Help
- How to add specific terms in a custom post type?
- Plugin Development using classes – Public & Private Callbacks
- Assigning categories to custom post types via a front-end form; only works for native post type
- Limit custom post type to the authors only on front-end!
- Update main post with same category when creating custom post to update the modified date
- Dynamic page for nav items used as filters
- Create posts inside CPT post
- Persist meta box choices throughout all posts of same post type
- ACF field check value of field on all other articles
- Change Search display for Custom Post Type
- Stored meta from attachment, video length?
- Duplicate posts in my custom loop
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- Featured image in custom post is being disabled
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- can’t see categories in appearance-menu-categories
- Function not pulling image or text from custom post type
- Custom Loop for custom post type. Compare by meta_value?
- Code in custom widget queries all posts, when it should only query the current post
- Add HTML before a specific div?
- Comments are not working on Custom Post Type
- How to I add count of custom posts listed in a post as a prefix to its title
- how to display custom taxonomies in front page
- add_rewrite_rule not working with custom post type
- How do loop categories post from according in WordPress? is it impossible to solve this problem?
- How can I remove the “Add New” button in my custom post type?
- Post the content of a specific “Custom Post Type” post within a post using a shortcode
- Copy custom field value to post title
- Filter Posts from the Main Query
- Enable taxonomies by post type in an array of CPTs
- sortable columns for multiple custom post types not working
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- Shortcode to return single custom post based on post taxonomy
- Accessing a protected property of a post
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- pagination problem listing custom post types of taxonomy in wordpress
- In the php, how can I have a category of a custom post type display?
- Custom Post By Category
- Display a list of sub-pages of Custom Post Type Parent Page
- test if something is a post or a taxonomy
- How to call Shortcode categories for custom post types?
- Query Custom Post Type by Tag