This looks like javascript. do_shortcode
is a php function. I’m not sure the full context, but at the very least, you need to wrap your php function in php tags like this and add an echo:
<?php // Start of php file ?>
<script>
var stockcounter = document.getElementsByClassName("stock in-stock");
if(stockcounter[0].innerHTML=='0 in stock') {
//Displays timer
stockcounter[0].outerHTML = "<?php echo do_shortcode('[fergcorp_cdt_single date="Feb 25 2019 18:45:00"]'); ?>";
}
</script>
I’m assuming this script is within a php file.
Related Posts:
- Run shortcode at certain resolution
- Trigger popup in a php if/else statement
- Creating own shortcode – echoeing php variable based on JS variable
- Calling PHP Titles inside Javascript Markup
- using shortcodes inside gravity forms
- How to output values from a loop into a javascript array
- Force ‘permanent’ post cache of shortcode results
- How can i iterate through this shortcode array?
- Set variable in javascript and using in my shortcode
- Is there a better way to output HTML as a shortcode?
- 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
- Deregistering a script in WordPress seems impossible
- Slide in Panel WordPress Post
- Shortcode Inside Class Not Working
- custom shortcode will not display the wrapped content
- Sending jsPDF documents to the server
- Shortcode content output but not in correct place
- How to prevent those PHP variables from being cached on WordPress?
- is_page “range” for if statement?
- Ajax return code 400
- How can I generate random numbers inside my shortcodes on each implementation?
- How can I add an alert (like the old javascript alerts) to my WP page?
- Pass PHP variable to JavaScript without inline JS
- Show post in slider
- How can I output a php value into a JS file within WordPress?
- PHP code inside shortcodes
- Use WP_Query in shortcode
- Shortcode API: How to get name that matched shortcode RegEx?
- Using shipped version of jquery
- Putting PHP variables into javascript [duplicate]
- Bridging TinyMCE js and WordPress PHP?
- Shortcode content filter?
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- Create shortcodes within foreach loop (using array)
- How do I display a user’s previous orders as a select box option on a product?
- Simple Plugin with custom javascript wont work – no console error
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- How can I use a modal window to display the current post in loops featured image?
- js file in root loading without
- class click counter save number
- Custom Theme, Custom shortcode not working
- Slider loading issue
- Append HTML Using Shortcode
- AJAX request status 200 but no actual “response”
- Button not refreshing page
- Ajax not working es expected (Returns 0)
- Why is file_get_contents returning page source?
- Plugin CSS not enqueing
- Use menu link or onClick to set a variable
- How to select the contents in the text view textrea in wp_editor?
- Creating a Multi-Level Associative Object Using AJAX
- Different loop output every x posts in custom post type
- WP functions in .js
- Adding custom directory and PHP files in wordpress
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- Ajax – Call to undefined function get_option()
- Showing a different gallery in a seperate post
- How to display posts by current user in a drop down
- Create own WordPress shortcode gallery
- Populate dropdown with Child Pages based on Parent Page chosen
- remove wp floating submenu in wp dashboard
- Get value from shortcode to do something
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- search and replace preword from author
- How to prevent XSS alter custom global javascript object & methods in WordPress
- How to exclude category ID from Looper in WordPress
- How to complete two other input fields, completed the first
- Add a specific part of current category page url to shortcode
- How to display data from custom table in wordpress phpmyadmin
- Calculating a large number of MYSQL queries as customshort codes, slow
- Status 400 for AJAX POST Request with admin-ajax.php
- How to inject variables into public-facing JS using wp_enqueue_script
- How to pass aa JS variable to PHP?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Ajax random number always the same
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- JS file work only in index page
- Need Help Fixing My Iframes [closed]
- wp_enqueue_scripts leads to error
- Javascript file is not working on single.php wordpress [closed]
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- Colon is Missing In My Website Url in WordPress
- How to change redirection route to a php page for making it only accessible by logged-in members?
- Integrating PHP into Javascript to display map markers with Google API – problem with wp_localize
- Save Search System
- dynamic dependent select dropdown
- Custom shortcode outputs plain text instead of HTML at top of post
- Passing UTM Parameters To Modify Page In WordPress
- How to send Ajax request from my plugin in admin dashboard?
- Incorrect MIME type for assets with Valet
- How to use wp_add_inline_style for custom CSS added via shortcode?
- Customizer: Multiple CSS styles on same element in Live Preview
- wordpress visual composer change grid builder post link
- Ajax load more button for comments wordpress
- How to register javascript variables in wp_localize_script?