Here's how you could do this:
- Install and Set Up ACF Plugin:
- Install and activate the Advanced Custom Fields plugin if you haven't already.
- Create a custom field group with a Radio Button field named "Availability" and two options: "Yes" and "No".
- Display the Content:
- In the template file where you want to display this content (e.g., a page template or a custom post-type template), you'll use the ACF functions to retrieve the field value and a simple PHP - if - statement to display the appropriate message.
- Assuming you've added your ACF field in your custom post-type template (e.g., single-{post-type}.php), here's how your code could look:
<?php
// Assuming you've already set up the WordPress loop
if (have_posts()) {
while (have_posts()) {
the_post();
// Get the ACF field value
$availability = get_field('availability');
// Display the message based on the selected option
if ($availability === 'yes') {
echo 'Available';
} elseif ($availability === 'no') {
echo 'Not Available';
}
}
}
?>
In this example, the get_field('availability') function retrieves the value of the "Availability" field, and then you use an if statement to display the corresponding message.
Remember to adjust the template file and field names based on your actual setup.
0 Comments