You can use get_field from ACF to check if the field is available and according to the documentation how you conditionally check if a field has contents.
<div class="wrapper">
<?php if (get_field('discount')) { ?>
<p>Discount: <?php the_field('discount'); ?></p>
<?php } else { ?>
<p>Price: <?php the_field('price'); ?></p>
<?php } ?>
</div><!--wrapper-end-->
This should give you what you want.
Related Posts:
- Search that will look in custom field, post title and post content
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- WP insert post PHP function dynamically generated Custom Fields
- Conditional to modify query results
- Create a random unique 6 digit number as custom field for custom post type
- Using several custom fields as custom post title
- Replace text in post from cvs
- Query & Order posts by custom fields
- get_post_meta not working on publishing
- Using custom field content as expression in IF statement [closed]
- Displaying custom field according to date
- Add additional field to custom post_type
- finding and using post type fields in WordPress
- Get data from PHP to JavaScript to set position of each post on front page
- CPT Repeatable Fields + Undefined Index
- Let users upload image(s) to the post from front end
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- How can I sort the order of multiple custom field values in a custom post type?
- How do I ensure that post_type and Taxonomy use the same slug?
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- Custom fields array to display it monthly
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- Sort custom post column by generated value?
- when looping through custom post data not appearing
- PHP Notice: Unidentified index
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Can’t pick up a field created with Advanced Custom Fields
- Get month and day from a Date Picker custom field
- Function not pulling image or text from custom post type
- Show Custom Post Type taxonomy term that matches custom field
- Order by custom field attribute
- Select Menu for Custom post Type does not save
- How do I filter a custom post type loop by a field?
- Get custom post fields and display them
- Send email on creation of custom post type and use get_post_meta()
- Do_Shortcode not working for Embed
- Inconsistent temporary 404s on whole install | PHP error with post-template.php
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- clients list using wordpress
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- How can I add dropdown widget/box to admin post page?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Custom field losing p tags on display
- Error after deleting Custom Post Type with a function (no trash used)
- Using posts and postmeta table to store custom Address Book Plugin data
- Change message given when deleting post from custom post type
- Frontend posting – everything saves other than checkboxes?
- Query Custom Post Types by date (custom field) range
- handling csv data with a custom post type
- query posts and custom post type with meta key
- Dynamically add / duplicate custom meta in custom post types
- Custom Post type and Custom Field WP_Query
- Custom query to filter posts that have current post as a taxonomy [closed]
- Custom Post Type Loop throws 500 error when used in widget
- Adding Show Less/More link to Custom Post Meta
- Received nothing after executing AJAX post function
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Categorize custom post type
- Function causing the loop display posting more (empty)
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type
- Set featured image to archive.php
- Get term name without a foreach loop
- Get custom post type categories to show up in menus
- Custome fields not displayed
- Is it possible to use array_walk() to append terms to an array of posts?
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- Custom post type name and assigning custom taxonomy
- Custom post types, disable fields
- Building a Portfolio and need some direction
- updating one custom meta field only
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- On saving Post My permalink is updated and category is removed automatically which cause the 404
- WP_Query get always custom post_type for first
- How to add specific terms in a custom post type?
- Limit custom post type to the authors only on front-end!
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- Show posts from WP Custom Post Type selected from a field in a metabox
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- How to make sure, that only the selected post is changing?
- Importing URLs of Audio Enclosures
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Retrieving custom post type fields without a post
- pre_get_posts with multiple post types AND a meta_key
- Search form to find custom meta box generated data
- Display Custom Post if custom field is marked
- predefined custom field on registration page
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Post object GUID adding http:/
- Query order by a numeric ACF field