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)
- Return HTML Template Page with PHP Function
- Display message once per session to users with a specific role
- ob_get_clean returns empty string, ob_get_flush outputs string
- lazy load comments wordpress on click
- How do I hardcode a WordPress shortcode into my theme?
- Using a javascript file to access a get posts array
- How to return multiples lines in a shortcode?
- Minify HTML, CSS, JS with PHPWee?
- Run a Parallel PHP Application with WordPress
- Access/update database with jQuery
- How do I turn a shortcode into PHP code?
- How to return a foreach inside a shortcode
- Customizer Show/Hide
- Page Reloads Before AJAX Request Finishes
- How do I fetch all comments per post via WP REST API?
- Shortcode content output but not in correct place
- Ajax return code 400
- PHP code inside shortcodes
- How do I display a user’s previous orders as a select box option on a product?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Pass php dynamic variable to shortcode
- Menu jumping when calling it via PHP
- Setting value of session with Ajax not working
- do_shortcode with custom field
- Remove echo from shortcode
- Shortcode to show the code
- How to optimize the IF condition with many conditions and same output [closed]
- Multiple do_shortcode in page template
- admin-ajax Firing Error 400 When Logged In
- Jquery window.send_to_editor function
- $wpdb returns duplicate posts
- Shortcode to find and replace URL
- How to put a form with php code into a variable or shortcode?
- How to add drag and drop functionalities to a div inside option panel
- Shortcode to embed Edit Account form not working
- Handling PHP/HTML inside the output of a shortcode function
- How to change logo by category
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Split shortcodes to array of shortcodes
- PHP error with a shortcode: “no suitable wrapper” for file_get_contents
- Run JS Code on userlog out
- How to make a conditional statement within $output in shortcodes.php?
- Covert WordPress Blogname into JQuery
- Shortcode displaying at the top of the page [duplicate]
- PHP variables in a post?
- Why wp_remote_get() fetches certain web pages while it doesn’t work for my localhost?
- How to exclude labels from certain categories in a shortcode?
- Hot to check if new posts have been published since page load and notify online users?
- 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
- Unable to display multiple parameters from url by javascript through shortcodes
- Settings API form – submit with AJAX
- Adding HTML Code to Replace Text in PHP
- Shortcode in Shortcode/HTML Graphics and Pictures
- Why is the current page loaded in the pop-up window and not the specified one?
- How to search order using database frontend short code WordPress
- How to add a shortcode which runs a .php file for the current post
- Get title of page containing post grid within the posts
- PHP multiple forms, same page, isset($_POST[]) not working?
- Ajax search box displays nothing if taxonomy doesn’t exist
- I have a lot of JavaScript erorrs after SSL someone can help me?
- Store data from JavaScript object to custom table in user account
- register dependency css and js inside a plugin class
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- Show the subcategory name based on current product
- Why my Ajax events are no longer detected after dynamic change of shortcode content
- Javascript Tab Gallery with Advanced Custom Fields
- Collapsible menu on post sidebar only expands and does not collapse
- Move Jquery.js to Footer
- Offset with ajax load more posts duplicates
- Shortcode in a $output statement
- Need help with PHP functions
- When using shortcode, content stops generating after the_content
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- PHP Shortcode – 500 error
- Run PHP Results inside WP Shortcode
- add bootstrap modal after login in wordpress
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- Help with my first Metabox helper class
- Add multiple JavaScript files to template header [duplicate]
- Add specific phrase after every product title including the discounted price? [closed]
- link to page_for_posts
- My title is showing after the shortcode
- Trouble figuring out how to get my button to submit comment
- Shortcode to include PHP file, pass various parameters to include?
- Redirect loop upon installation of my plugin
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only