A simple google search led me to this: You can’t run PHP with javascript. JavaScript is a client side technology (runs in the users browser) and PHP is a server side technology (run on the server). If you want to do this you have to make an ajax request to a PHP script and have that return the results you are looking for.
Related Posts:
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Post repeated when opening in overlay, how do I solve this? [closed]
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- How to display user nickname (not display name) in PHP template?
- Custom Template 404 for specific custom post type
- Ajax return code 400
- An unwanted inline style is added to my body tag
- How to properly insert a link to a template in WordPress?
- 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?
- Custom field value not saving when it contains a URL?
- Using shipped version of jquery
- Putting PHP variables into javascript [duplicate]
- Bridging TinyMCE js and WordPress PHP?
- Automatically add custom CSS to new posts using a category template
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- 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?
- Render ninja form inside markup
- js file in root loading without
- class click counter save number
- Trigger popup in a php if/else statement
- Slider loading issue
- How can I load a PHP page without using a Template?
- AJAX request status 200 but no actual “response”
- Button not refreshing page
- Ajax not working es expected (Returns 0)
- 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
- WP functions in .js
- Adding custom directory and PHP files in wordpress
- how could I load a different template part by page
- Ajax – Call to undefined function get_option()
- creating a second image attachment template?
- Mass update excerpt
- Populate dropdown with Child Pages based on Parent Page chosen
- remove wp floating submenu in wp dashboard
- How can I get a single php file that is the equivalent of an existing WordPress page?
- 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 complete two other input fields, completed the first
- 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?
- Get and insert order email address to the PHP template inside HTML text
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Custom search results page not working with empty search
- Ajax random number always the same
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- How to show single category archive
- 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]
- code is skipping a div
- Issues getting PHP to display in category pages
- 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
- 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
- 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?
- Change title only in dynamic page
- Open post-content in archive page in a Modal box with bootstrap
- Creating own shortcode – echoeing php variable based on JS variable
- How to add a do_action on refreshing of WP customizer?
- How to pre populate a form field with a link of a current user’s author profile?
- parts of url disappear when using # inside href=”” [closed]
- How to pass Select value from Javascript to PHP to generate select option on change
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- Menu jumping when calling it via PHP
- How does wp_enqueue_scripts work?
- wp attempt focus, disabling without touching core
- Setting value of session with Ajax not working
- AJAX success response is not working but it’s saving my changes
- PHP array to JS array to use in google map
- PhantomJS with wordpress
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Media Upload , file name changed automatically
- Add / Update Custom Fields After Select Pictures in Media Window
- Post repeating with infinite scroll
- WordPress Scripts Being Loaded in Footer
- How can I edit the content in index.php? [duplicate]
- Fancybox type popup window that’s not an iframe
- Generate sidebar depending on height of post
- Accessing WPDB Multidimensional JSON Array w/ Javascript
- Woocommerce Show Single Product on Homepage