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
- How to capture number input from wordpress form into acf field in woocommerce
- add class to woocommerce single product template gallery thumbnails if media attachment ACF field toggled (true/false)
- Exclude function for custom pages, exclude custom ACF fields
- Display posts in correct month order using single date custom field
- Advanced Custom Fields [closed]
- `update_post_meta` not working anymore
- How to make a cookie be on the whole site instead of being on a specific page/
- Order a WP_Query by meta value where the value is an array
- How to use functions [closed]
- PHP Output also in Child theme, but different
- Splitting the_content() by size?
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Fallback image URL if no featured image exists via a shortcode function
- Unable to render custom field after attempt to generate a list of recent post in page template
- How to style injected code in header section?
- Is there a hack for using is_page() within the function.php file?
- Query for user roles
- Add a custom class to the body tag using custom fields
- Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS
- Define category ID using get_post_meta
- how to enqueque code in a php file from functions.php
- Class property seems to lose scope, attached to save_post action?
- Randomize Color Scheme Selection in Theme
- Add a counter for mouseovers (custom field)
- Extract and display user infromation on an automatically created page
- Must filter functions receive all arguments passed to them?
- Custom Taxonomy Select Menu: Setting default option value?
- How to add author’s posts link (HTML + PHP) inside a function to output it
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- ACF Unexpected T_CONSTANT_ENCAPSED_STRING [closed]
- How to Display a List of Child Pages For a Parent Page in WordPress
- Only load certain artists on this page
- Nav-Menu not showing up
- Show different website layout if no sidebar added
- Creating customized php files in theme folder