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
- “acf/load_field” Critical error upon saving/updating WooCommerce products [closed]
- Put ACF function output code the_terms
- Cannot Access ACF Field Values via my Plugin
- How to create advanced custom fields for backend content
- Exclude function for custom pages, exclude custom ACF fields
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- How can I modify the permalink via a filter?
- wp_set_object_terms and arrays
- Shortcode putting html such as
- How to handle a custom form in wordpress to submit to another page?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How do I create comment-reply-button using element not
- Use ajax to update_post_meta
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Can an array be used as a meta_query value?
- If Meta Checkbox is checked, do something?
- How to check If Oembed is empty or not
- Show custom field if it exists, and show different elements if it doesn’t
- ACF check if variable has http, if else return string
- Can’t load WP function into external function
- Custom field value not saving when it contains a URL?
- Image as Sales Badge
- WSoD being caused by this piece of code
- Sort posts by custom fields value using dropdown menu
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Need Help Fixing My Iframes [closed]
- Fatal error: Uncaught Error: Call to undefined function test()
- Return a numerical function value in Customizer controls
- Trouble checking if custom woocommerce checkout field is empty or not
- Css loads very slow [closed]
- Show when user is online/offline in real time on user_profile.php
- Scrape external webpage for first image and add it to new post
- Add / Update Custom Fields After Select Pictures in Media Window
- theme_root returning a truncated URI