What is the main purpose of the Advanced Custom Fields (ACF) plugin in WordPress?
ACF allows you to add custom fields to WordPress posts, pages, and custom post types easily, so you can store and display extra information beyond the default content.
Click to reveal answer
beginner
How do you display a custom field value created with ACF in a WordPress theme template?
Use the PHP function the_field('field_name'); inside the template file to show the value of the custom field named 'field_name'.
Click to reveal answer
intermediate
What is a Field Group in ACF?
A Field Group is a collection of custom fields that you create and assign to appear together on specific edit screens in WordPress, like posts or pages.
Click to reveal answer
intermediate
Explain the difference between get_field() and the_field() functions in ACF.
get_field() returns the value of a custom field so you can use it in your code, while the_field() directly prints the value to the page.
Click to reveal answer
advanced
How can you make a custom field appear only on posts of a specific category using ACF?
In the Field Group settings, use the Location Rules to set the field group to show only if the post is in the chosen category.
Click to reveal answer
Which ACF function would you use to get a custom field value without printing it?
Aget_field()
Bthe_field()
Chave_rows()
Dthe_post()
✗ Incorrect
get_field() returns the value so you can use it in your code, while the_field() prints it directly.
What is the purpose of a Field Group in ACF?
ATo backup WordPress content
BTo create a new WordPress post type
CTo group multiple custom fields together for display on edit screens
DTo style the WordPress admin dashboard
✗ Incorrect
Field Groups organize custom fields so they appear together on specific edit pages.
How can you restrict a Field Group to show only on posts in a certain category?
AChange the WordPress permalink settings
BEdit the WordPress theme's CSS
CAdd a shortcode to the post content
DUse Location Rules in the Field Group settings
✗ Incorrect
Location Rules let you control where Field Groups appear based on conditions like category.
Which of these field types is NOT a default option in ACF?
ASQL Query
BImage
CText
DRepeater
✗ Incorrect
ACF does not have a built-in 'SQL Query' field type; others like Text, Image, and Repeater are standard.
What does the have_rows() function do in ACF?
AGets the value of a text field
BChecks if a repeater or flexible content field has rows to loop through
CDeletes a custom field
DCreates a new field group
✗ Incorrect
have_rows() is used to loop through rows in repeater or flexible content fields.
Describe how you would create and display a custom text field on a WordPress post using the Advanced Custom Fields plugin.
Think about the steps from setup in admin to showing on the site.
You got /4 concepts.
Explain how ACF's Location Rules help control where custom fields appear in WordPress.
Consider why you might want fields only on certain pages or posts.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the Advanced Custom Fields (ACF) plugin in WordPress?
easy
A. To add and manage extra custom fields without changing the database manually
B. To create new WordPress themes automatically
C. To speed up WordPress site loading times
D. To backup WordPress site data
Solution
Step 1: Understand what ACF does
ACF allows users to add custom fields easily without coding database changes.
Step 2: Compare options
Only To add and manage extra custom fields without changing the database manually describes adding and managing extra fields without manual database edits.
Final Answer:
To add and manage extra custom fields without changing the database manually -> Option A
Quick Check:
ACF purpose = add/manage custom fields [OK]
Hint: ACF is for custom fields, not themes or backups [OK]
Common Mistakes:
Confusing ACF with theme builders
Thinking ACF speeds up site loading
Assuming ACF handles backups
2. Which of the following is the correct way to retrieve a custom field value named subtitle using ACF in a WordPress template?
easy
A. the_field('subtitle');
B. fetch_field('subtitle');
C. get_field('subtitle');
D. custom_field('subtitle');
Solution
Step 1: Identify the correct ACF function for retrieving values
The function get_field() returns the value of a custom field.
Step 2: Check other options
the_field() echoes the value, not returns it; others are invalid functions.
Final Answer:
get_field('subtitle'); -> Option C
Quick Check:
Retrieve field value = get_field() [OK]
Hint: Use get_field() to get value, the_field() to print directly [OK]
Common Mistakes:
Using the_field() when value is needed for logic
Using non-existent functions like fetch_field()
Confusing echo and return functions
3. Consider this code snippet in a WordPress template using ACF:
$subtitle = get_field('subtitle');
if ($subtitle) {
echo "
$subtitle
";
} else {
echo "
No subtitle found
";
}
What will be the output if the custom field subtitle is empty or not set?
medium
A. PHP error will occur
B.
C. Nothing will be displayed
D.
No subtitle found
Solution
Step 1: Understand the if condition
The code checks if $subtitle has a value. If empty or not set, condition is false.
Step 2: Check the else block output
If false, it echoes "
No subtitle found
".
Final Answer:
<h2>No subtitle found</h2> -> Option D
Quick Check:
Empty field triggers else output [OK]
Hint: Empty fields trigger else block output [OK]
Common Mistakes:
Assuming empty string prints empty <h2>
Expecting no output when field is empty
Thinking PHP error occurs on missing field
4. You have this code in your WordPress template:
echo get_field('price');
Sometimes it shows nothing and breaks the page layout. What is the best way to fix this issue?
medium
A. Remove the get_field() call completely
B. Check if the field has a value before echoing it
C. Use the_field() instead of get_field()
D. Change the field name to 'price_value'
Solution
Step 1: Identify the problem cause
Echoing an empty or null field can break layout if no fallback is provided.
Step 2: Apply a check before echoing
Use if (get_field('price')) to ensure value exists before output.
Final Answer:
Check if the field has a value before echoing it -> Option B
Quick Check:
Always check field value before output [OK]
Hint: Always verify field value exists before printing [OK]
Common Mistakes:
Removing field call instead of fixing output
Using the_field() which echoes without checks
Changing field name without updating code
5. You want to display a list of team members with their custom fields: name, role, and photo. Which approach correctly uses ACF to loop through a repeater field called team_members and display each member's info?
hard
A.
if (have_rows('team_members')) {
while (have_rows('team_members')) {
the_row();
echo get_sub_field('name');
echo get_sub_field('role');
echo '';
}
}