Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In the Custom iFrame plugin, a hook has been added that lets you add a custom title attribute (or any other attribute) to your iframe widget — even if you’ve added the same widget multiple times on the same page.
- Here’s how you can do it step-by-step 👇
- ✅ Step 1: Add a Custom ID to your iframe widget
- 1. Open the page with Elementor.
- 2. Click on the iframe widget.
- 3. Under the Content tab, scroll to the Advanced section.
- 4. Add a unique ID like this: contact-form-iframe or pricing-table-iframe — anything that helps you identify the widget.
- ✅ Step 2: Add this code snippet to your theme’s functions.php file or use the Code Snippets plugin:
- -----------------------------------------------------------------------------------
- add_filter( 'custif_iframe_attributes', function( $attrs, $settings ) {
- $custom_id = $settings['custif_custom_id'] ?? '';
- if ( 'iframe-one' === $custom_id ) {
- $attrs['title'] = 'Contact Form';
- } elseif ( 'iframe-two' === $custom_id ) {
- $attrs['title'] = 'Pricing Table 2';
- }
- return $attrs;
- }, 10, 2 );
- -----------------------------------------------------------------------------------
- ✅ Step 3: Add more conditions if needed
- You can keep adding more elseif conditions in the same code if you want to apply different titles for more iframe widgets.
- -----------------------------------------------------------------------------------
- elseif ( 'video-iframe' === $custom_id ) {
- $attrs['title'] = 'Promo Video';
- }
- -----------------------------------------------------------------------------------
- That’s it! 🎉
- This gives you full control to set different titles (or other attributes) for each iframe based on the
- custom ID you set.
Advertisement
Add Comment
Please, Sign In to add comment