First, don’t echo your php, but assemble everything in a string, let’s say $titlestring
.
Next, make this string available for access by the javascript (the slug is the one you used to register the script):
$params = array (
'titlestring' => $titlestring,
);
wp_localize_script ('your-script-slug', 'IframeTitle', $params);
Finally, access the variable in the script:
'<div class="title">' + IframeTitle.titlestring + '</div>' +
Related Posts:
- Is there a better way to output HTML as a shortcode?
- How do I use Shortcodes inside of HTML tags?
- WordPress Ajax always returns a 404 error
- WordPress Shortcode and Dynamic CSS
- Calling a method from functions.php on a click of a button
- Run shortcode at certain resolution
- Nice scroll to wordpress
- Javascript code inside “” in core WordPress files .php
- Minify HTML, CSS, JS with PHPWee?
- Placing raw HTML inside a WordPress shortcode
- Slide in Panel WordPress Post
- Shortcode content output but not in correct place
- Show post in slider
- Trigger popup in a php if/else statement
- Populate dropdown with Child Pages based on Parent Page chosen
- search and replace preword from author
- How to change redirection route to a php page for making it only accessible by logged-in members?
- Creating own shortcode – echoeing php variable based on JS variable
- parts of url disappear when using # inside href=”” [closed]
- How create a Shortcode with hover and complex options
- Noscript not working as it should in wordpress site
- Add Codepen animation as Preloader to WordPress
- HTML escaping data with ajax requests
- Using ob_start and ob_get_clean with wordpress shortcode
- Override user-edit.php to design own profile page
- Handling PHP/HTML inside the output of a shortcode function
- Link to page with posts of specific type
- Replacing WordPress Icons (menu,icons32, etc)?
- Shortcode displaying at the top of the page [duplicate]
- Is it possible to isolate and use WordPress functions outside of wordpress
- Time Delay a URL Redirect for Specific Page
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- html form: redirect page after form completes submit function and posts data
- using shortcodes inside gravity forms
- WordPress User Meta value variable into Google Gauge Chart
- Search bar for wp menu
- Adding HTML Code to Replace Text in PHP
- Executing php on button press
- Add other class content with reference class value
- Shortcode in Shortcode/HTML Graphics and Pictures
- Using Google Analytics in an enqueued JS file
- couldnt show short code atts in category
- separate list of programs in html/javascript coming from php
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- How do I disable cache for a certain page?
- How can I edit the final HTML structure of the whole web page
- WordPress Slider is not working
- How to return html as a string from php for WordPress
- Changing Date Format on Custom Meta Data w/shortcode call
- Show subcategory name selected in specific category woocoommerce
- How can I create a shortcode from an html and php code written together
- How to output values from a loop into a javascript array
- sessionStorage saves input value in browser but it is not loaded in the form field
- Collapsible menu on post sidebar only expands and does not collapse
- Replacing entire tag with shortcode – JavaScript [duplicate]
- Target a specific container to style on WordPress storefront theme
- scroll scrpit to particular button position to next id when click button
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Force ‘permanent’ post cache of shortcode results
- How can i iterate through this shortcode array?
- Where to find the html for WordPress site? [closed]
- I need help implement a Javascript code into the PHP file
- Show contact 7 form in popup
- Trying to customize wordpress drop down categories
- Set variable in javascript and using in my shortcode
- Load wp_editor on button click
- Slick slider not working on wordpress
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)
- How do I make an HTML table from a database table?
- Place page title in header?
- Shortcode to insert
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- How to get year, month and hour in WordPress?
- Using Echo in ShortCode – Stuck
- Two posts in same div – WP loop
- Multiple do_shortcode($content) within one shortcode
- WordPress menu deletes when trying to add a hook
- Can A Shortcode Get HTML/Text From Content And Return It Twice With Added HTML?
- Making Quote Plugin more efficient
- How to test nonce with AJAX – Plugin development
- Create shortcodes within foreach loop (using array)
- Need Help Fixing My Iframes [closed]
- wp_enqueue_scripts leads to error
- Passing UTM Parameters To Modify Page In WordPress
- Only first shortcode gets executed
- Function returns text instead of html [closed]
- trying to put an active hover to my custom nav category buttons [closed]
- Accessing an API with jQuery and AJAX
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Configure WordPress to Use Responsive Image Rendering
- Pulling Products from an API
- Call jQuery function from PHP?
- Create dynamic content from one WP page to multiple other pages
- get_option(‘admin_email’) not working in wordpress when using ajax call
- Generating a number based on post ID
- Disable Typed Parameters for JavaScript in PhpStorm? [closed]
- Losing Session ID and sessionStorage when navigating to other domains on Multisite