Use the in_category() function, like this:
<?php if ( in_category( 4 ) ) : ?>
<div class="event-post-icons">
<ul>
<li class="single-post-date"><?php the_field('event_date'); ?></li>
<li class="single-post-time"><?php the_field('event_time'); ?></li>
<li class="single-post-price"><?php the_field('booking_fee'); ?></li>
<li class="single-post-palce"><?php the_field('event_location'); ?></li>
</ul>
</div><!-- /event-post-icons -->
<?php endif; ?>
If you are using this to test a post outside of The Loop, you would need to add the post id:
<?php if ( in_category( 4, $post_id ) ) : ?>
Related Posts:
- Where are custom field values stored in the database
- Custom post meta field effect on the performance on the post
- Using TinyMce with textareas in meta boxes on custom post types
- Having different sidebar content for MANY pages?
- How can I fetch CSS from JSON WP REST API response
- How to set a default meta value for custom field
- Create meta boxes that don’t show in custom fields
- How To Create a Metabox of HTML Content with Instructions For Editors When Editing a Post or Page?
- Plugins won’t recognize my plugin’s hidden custom fields
- wp_editor in add_meta_boxes does not show gallery
- Calling Specific Pages with wp query Part II
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- If value present, order posts by two consecutive custom fields
- Copying Custom Meta Values from existing post to a duplicate post
- Save page data to an xml file
- How to filter a dd/mm/yyyy date from a custom field in a query
- List posts with common custom field value
- Create Posts using Import>RSS/WXR/XML and pass values to Custom Fields
- Best way to add custom / magic / flutter fields into RSS feed
- Importing users to Buddypress with custom fields
- How to save a ToggleControl value in a meta field?
- How to get multiple checkboxes in one meta field
- How to get customfield value by woocommerce product ID
- How do I get the url slug inside the dashboard for a custom post type?
- How do I use Ajax to build a dropdown of custom fields based on a post selected in previous dropdown?
- Register rest field for specific user
- Custom Field Suite A little problem
- Meta query with timestamp using WP_query
- Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)
- load custom fields on click
- Add Custom Field to a template page backend
- custom field not saved
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Auto-remove custom field with no value on publish
- How to schedule a custom field value update?
- Custom Fields box in the post editor: Replace textareas with input elements
- Hide custom meta data if empty
- Advanced search for meta fields
- Woocommerce Product Custom Select List (not variation)
- Passing args to WP_User_Query am I using meta correctly?
- How to find a post using XML-RPC without knowing ID
- How to get latest post value if first post is empty in wordpress
- Custom fields attached to a page template only show on edit screen when page is saved
- Value from custom field is not being displayed?
- Specific coditional usage [closed]
- Can I access a post meta field before the loop?
- wrap text around custom fields array
- Displaying page image in the footer automatically
- Hide custom column in admin template screen (Elementor) [closed]
- How to I make my post title link to a custom field
- Show image if author meta (profile fields) exists outside loop
- How can i retrive a text from a custom field
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Is it possible to populate a custom field with content from a page
- How can I check if a custom field was updated?
- Buik update custom field values from external API
- Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle
- award points to a user each time they update their cpt post
- TinyMCE custom button retrieve value from custom field
- Update post meta data (custom field) by post link
- Change a custom field value after X number of seconds
- Changing order in which custom fields appear in dashboard
- Let Users Filter Posts by Custom Fields
- Run Function if Order Meta Exists – WooCommerce
- Jquery on custom-field backend
- Custom fields won’t update
- How to use custom fields like Title to show value in content?
- Populate custom checkout fields with data from previous orders
- User query – getting values for custom meta keys/fields
- Expire Date Condition not Working ACF WordPress
- Making custom meta box required (with error message if not filled in) on Gutenberg
- Changing form action based on selected value
- trying to add extra field using hooks
- Can’t set custom meta fields for a post
- Very large list of options for BuddyPress profile fields
- Hiding Dropdown Fields
- Custom fields with wordpress
- Change Order of Sections Using Custom Fields
- what would be a good example of a php dynamic code to display contents of textarea?
- How to add content with a filter when there’s no content in the editor
- Append custom field items to content from plugin
- Text in header as a page – hide from Web crawlers
- When post is updated, custom metadata in text area field is overwritten
- How to use a custom field for search engine optimization
- Fetch data from a WP page with same name as current username
- Getting content from custom fields of different pages on a single page
- Custom Fields – How can I remove the publish option for certain users
- Can i categorise my meta box?
- How to overwrite a value for a custom field?
- WordPress archives by custom field and date
- Decouple page name from page title
- When editing a post with a custom meta box the values aren’t displaying correctly
- Function to retrieve a picture if there is no picture is attached
- Show posts containing or not custom field
- custom field as a boolean with a checkbox?
- add_post_meta insert null value into Database
- Website that sells statistics
- Extract array from custom field
- extra post fields for url + youtube video / implementation
- How to apply Local Business Google Schema dynamically on a Custom Post single template?