Due to the ‘ vs '
that was already mentioned and since your code logic is correct, I suggest you make sure you’re comparing integers, not strings. PHP can be surprising when working with strings as numbers, so cast them as int. Also, make sure you’re getting the correct values by adding $post_id
, like this:
$price = intval(get_field('price', $post_id));
$reduced_price = intval(get_field('reduced_price', $post_id));
“117900” is considered smaller than “99900” as strings. PHP will compare ASCII values of the first character from the string – “1” vs “9” in our case. If the first character from the first string is smaller, the whole first string is smaller. If they’re equal, it moves on to the next character, an so on.
Related Posts:
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Delete images from media library when user deletes an image from ACF Gallery
- ACF Date fileds to Age Convert [closed]
- Display all values of custom a field created with ACF on a page
- How to automatically apply woocommerce product title to all product images alt tags?
- Inserting Gravity Form checkbox values into Advanced Custom Fields [closed]
- If Custom Field is empty don’t display div
- Add custom field to attachments in a specific category
- The values of custom fields are not available functions.php
- How can update custom meta for all posts
- Problem with ACF shortcode with Repeater Field in WordPress? [closed]
- Unique key for each row in a repeater field
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- Importing hard coded custom field into acf field
- Passing the custom field values in the wp_get_current_user array function
- ACF: how do I get the fields and its values of a specific group?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Firing schema via code in functions.php doesn’t work
- How to use thumbnail size of image if I’m only using src to get image
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Trying to retrieve post meta
- Redirect to another page using contact form 7? [closed]
- Which PHP page is the Default Posts Page
- Advanced Custom Fields – display label and value only if value entered
- Download PDF after CF7 form submission
- How to check if a PHP string is different than meta field?
- Can’t save php string to a custom field
- Why does this update_post_meta function not delete the custom field itself?
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- How to show/hide php table rows based on the content of custom fields
- Custom meta box values are not getting saved for my custom post type
- HTML Special Characters in URL string [closed]
- Creating an image from a custom field
- How can I count ACF sub_field with a certain value
- WP All Import / Update stock quantity from multiple XML files
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to add data to a custom field at the wp_users table?
- Hide a div when a custom field is empty
- Including Custom fields within the_content
- Conditional On custom field plugin metabox
- Updating Metadata with Shortcode
- Products listing check if meta checkbox is checked
- Trying to update Woocommerce meta values
- Is it possible to update the dataset using update_post_meta
- Block error message in foreach loop when looping through ACF field
- Hide a div if the fiels is empty
- Query on a repeater date (acf)
- ACF – Can’t get custom post type by taxonomy
- Advance custom fields variable with if statement & Function
- How do I get the value of a current user’s custom field?
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Display custom meta box in my template file
- Appending an ACF custom field to the page title
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Creating posts with php-script + csv
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- How to call a function only once (global variable scope)
- Multiple is_page() in page.php
- How to correct schedule my event weekly with wp_schedule_event()
- Looking for most performant way to execute several similar WP queries within shortcodes
- How do I display a user’s previous orders as a select box option on a product?
- How to combine wordpress_logged_in cookies in one cookie?
- Two Different Links for Same Product – WooCommerce [closed]
- Modify custom field input data before creating a new post
- Get my site session in wordpress?
- is_user_logged_in() not working in AJAX validation call
- Register a menu – Error Header
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- How to create a field in customize and show that in header.php?
- Get user custom field value on function.php
- PHP Output also in Child theme, but different
- Dynamically Generate Functions and Hooks
- Need help for some PHP code
- Adding HTML Code to Replace Text in PHP
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- register_block_type is not working properly
- PHP “warning include_once(): Failed to open stream” Simple HTML DOM in WordPress Child Theme
- cURL needing to loop through all “next_page”
- Javascript Tab Gallery with Advanced Custom Fields
- How can I get my pagination loop to display the correct number of total pages?
- Get posts by id using shortcode
- Is it possible to replace ‘attachment’ with another word?
- Generate a radius search of custom post type locations
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Show post/page into div using function
- Getting a value from a custom field from a page that shares a parent with the current page
- PHP get_category() function redeclared
- How to trim content AND retain HTML?
- WordPress – registering sidebar and adding a button directly after .textwidget
- Where can I find the code for the menu page meta boxes?
- WordPress adding in site URL to header links
- Error on Include php:/usr/share/pear
- I am trying to replace a string with other from function.php
- posts_clauses drop ACF get_field function
- How to save a post to a Custom post type and copy the information to another Custom post type?