First, let’s put all the “payvalue” radio options into an array. This will allow us to then display them all using a foreach
loop to reduce redundancy and the chance to make a mistake:
$payValueOptions = [126500000, 252000000, 503000000];
Now, let’s render the fields in a foreach
loop:
$selectedPayValue = $_GET['price'];
foreach ($payValueOptions as $option):
$isChecked = ($selectedPayValue == $option);
?>
<input type="radio" name="payvalue" value="<?php echo $option; ?>" <?php $isChecked ? 'checked' : '' ?>><br>
<?php
endforeach;
Related Posts:
- Combine CSS and JS files from plugins
- How to call a PHP function from Javascript in WordPress
- Display message once per session to users with a specific role
- How to preserve PHP modifications while upgrading WordPress?
- Nice scroll to wordpress
- How to use the php if statement [closed]
- lazy load comments wordpress on click
- How to block specific keywords from searching on WordPress?
- How to create filterable portfolio in WordPress?
- Get value of contact form 7 radio button [closed]
- Using a javascript file to access a get posts array
- Minify HTML, CSS, JS with PHPWee?
- Run a Parallel PHP Application with WordPress
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- admin-ajax.php responding with 0
- How can the plugin directory path be returned into ?
- Customizer Show/Hide
- Page Reloads Before AJAX Request Finishes
- How do I fetch all comments per post via WP REST API?
- Deregistering a script in WordPress seems impossible
- How to prevent those PHP variables from being cached on WordPress?
- Ajax return code 400
- Pass PHP variable to JavaScript without inline JS
- Show post in slider
- How do I display a user’s previous orders as a select box option on a product?
- Trigger popup in a php if/else statement
- How to select the contents in the text view textrea in wp_editor?
- How to pass aa JS variable to PHP?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- 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
- Menu jumping when calling it via PHP
- Setting value of session with Ajax not working
- Click a radio button must set textfield value
- Accessing WPDB Multidimensional JSON Array w/ Javascript
- wordpress wp_enqueue_script() not working
- How to optimize the IF condition with many conditions and same output [closed]
- admin-ajax Firing Error 400 When Logged In
- Jquery window.send_to_editor function
- How to add drag and drop functionalities to a div inside option panel
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Override user-edit.php to design own profile page
- How to change logo by category
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Incrementing PHP variable onclick to display posts by month
- Run JS Code on userlog out
- Covert WordPress Blogname into JQuery
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- PHP variables in a post?
- How to sort posts by active category in WordPress?
- Hot to check if new posts have been published since page load and notify online users?
- Additional file upload in Gutenberg page options/featured image
- 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
- Variation prices breakdown only for single product page
- Unable to display multiple parameters from url by javascript through shortcodes
- Settings API form – submit with AJAX
- Post form – AJAX won’t upload featured image – Plugin development
- Adding HTML Code to Replace Text in PHP
- How to add JS script in specific pages in WordPress?
- Load more posts using AJAX based on posts inside WP_Query
- How can i find wrong word in search box and replace with correct word
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- Ajax search box displays nothing if taxonomy doesn’t exist
- Display one random image from Media Library
- Google CSE Malfunctions via Chrome/Safari on Mobile When Clicking on Either Search Icon/Menu Icon. How to Make Google CSE Default Theme Search
- 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
- Using wp_editor() when not logged stopped working
- Modifying child theme’s header
- Show the subcategory name based on current product
- Show subcategory name selected in specific category woocoommerce
- Javascript Tab Gallery with Advanced Custom Fields
- Collapsible menu on post sidebar only expands and does not collapse
- Move Jquery.js to Footer
- ajax polling with admin-ajax.php
- wordpress all post filter by year
- Generate a radius search of custom post type locations
- custom field – changing an element or background of id div – different versions not working
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- How can i iterate through this shortcode array?
- A javascript function that simply runs a php function on the plugin
- Display text of price (minus 20%) on every product page in a sentence.
- Populate an array from the loop, and then read the array into JS
- Why isn’t my custom Javascript showing up in my custom template?
- Help with my first Metabox helper class
- Execute PHP code in Javascript onclick
- Add multiple JavaScript files to template header [duplicate]
- Trouble figuring out how to get my button to submit comment
- Import and use a variable in additional settings of Contact Form 7 [closed]
- Having trouble customizing toolbar on wp_editor
- Load wp_editor on button click
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only