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)
- Calling a function via a shortcode in javascript
- How to make this shortcode not refresh the whole page when i use it on frontend
- Creating a WordPress shortcode
- Data fetch and delete by ajax request
- JavaScript, best way to use data from the loop
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Simple Plugin with custom javascript wont work – no console error
- Using the echo command adds unwanted br tags to source
- Javascript file is not working on single.php wordpress [closed]
- How to send Ajax request from my plugin in admin dashboard?
- Customizer: Multiple CSS styles on same element in Live Preview
- AJAX success response is not working but it’s saving my changes
- WordPress wp-admin redirect and exception
- Cant display an image via PHP in wordpress
- Set document title through shortcode plugin
- Mysterious letters appearing at the top of a few pages
- Current WordPress Page Title as Search Parameter into A Tag
- How can i show specific Category List?
- Using Javascript On Page – Header and Footer Now Missing
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- Changable favicon
- Multisite – Display different header content based on which site is accessed
- How do you change the tag font size in the repeater-template.php [closed]
- PHP tag in post content makes wordpress go crazy
- Limit the number of successful logins
- Problems with plugin that fetches data from database with ajax
- Dynamic Gallery
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- get_post_meta returns on side but it doesn’t return on bottom of admin page