Php is a server-side language. Meaning the code is executed and the user will receive the compiled html code. The only way to execute php code as user is through ‘post’ or ‘get’ requests. So essentially loading a new page. The only workaround is using ajax to load new php code dynamically.
But it may also be that what you plan to do is possible to do with just Javascript. Echoing “pressed” is possible in Javascript using .innerHTML function. Or when you want to show a shortcode-widget on button click you could load it from the beginning and just set it to being visible on button click with Javascript and css.
Related Posts:
- WordPress Ajax always returns a 404 error
- Calling a method from functions.php on a click of a button
- Nice scroll to wordpress
- Javascript code inside “” in core WordPress files .php
- Minify HTML, CSS, JS with PHPWee?
- Slide in Panel WordPress Post
- Show post in slider
- 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?
- parts of url disappear when using # inside href=”” [closed]
- Noscript not working as it should in wordpress site
- Add Codepen animation as Preloader to WordPress
- HTML escaping data with ajax requests
- Override user-edit.php to design own profile page
- Calling PHP Titles inside Javascript Markup
- Link to page with posts of specific type
- Replacing WordPress Icons (menu,icons32, etc)?
- 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
- WordPress User Meta value variable into Google Gauge Chart
- Search bar for wp menu
- Adding HTML Code to Replace Text in PHP
- Add other class content with reference class value
- Using Google Analytics in an enqueued JS file
- 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?
- WordPress Slider is not working
- Show subcategory name selected in specific category woocoommerce
- 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
- 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
- Where to find the html for WordPress site? [closed]
- I need help implement a Javascript code into the PHP file
- Trying to customize wordpress drop down categories
- Is there a better way to output HTML as a shortcode?
- Load wp_editor on button click
- Slick slider not working on wordpress
- Local wordpress install only shows home page, all other pages Not Found
- How do I make an HTML table from a database table?
- How to get the custom header image’s alt text?
- Modify previous and next text from pagination links
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to create a custom config file and get data using inline JS in a wordpress page
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- To echo or not to echo?
- Correct syntax to html php conversion
- How can I output a php value into a JS file within WordPress?
- How to test nonce with AJAX – Plugin development
- Slider loading issue
- Getting a specific post values to another div or modal
- How to complete two other input fields, completed the first
- WP grandchild categories in nested ul li
- Need Help Fixing My Iframes [closed]
- Passing UTM Parameters To Modify Page In WordPress
- 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?
- Settings API callback function inserts html quotes from nowhere
- Add / Update Custom Fields After Select Pictures in Media Window
- How i can get post data from database when i am getting post id from url in wordpress
- trying to put an active hover to my custom nav category buttons [closed]
- Where can I find the inline-css of my theme header?
- How do I get my Javascript scripts working?
- Make textarea required. Help [closed]
- Website completely messes up when logging out
- How can I use custom menus with a Bootstrap WordPress theme?
- ‘Bones’ theme: Load stock scripts in footer instead of header?
- go to home page when i select default in select-box
- How to redirect non logged in mobile users to page on same site?
- HTML Form Question
- Decode and Decrypt Azure B2C OpenID Authorization Token, Use Response in API Call (Example Token Within)
- Slug duplicates once clicking on link
- How do I integrate vanilla Javascript to a wordpress website?
- My single.php page skips the first div tag
- opens like sitename.com/URL
- How to display post meta bellow every posts
- Filtering markers on google map by WordPress category[SOLVED]
- Call jQuery function from PHP?
- Can’t get_users info by using json_encode
- Why this plugin is not working?
- get_post_meta is always empty when I use wp_mail
- Facebook share button only share the_permalink(), without thumbnail, tilte, excerpt, etc
- get_option(‘admin_email’) not working in wordpress when using ajax call
- Implement “No related posts for this entry” into the loop?
- ACF repeater image in video poster with jquery
- Advanced Custom Fields Show PHP in Text Areas
- Disable Typed Parameters for JavaScript in PhpStorm? [closed]
- How can I use AJAX in child theme template?