The method
Use this prompt to generate PHP code for ACF field groups. Paste the prompt into your LLM of choice, specifying the desired field types, labels, and settings. Copy and paste the generated code directly into your theme’s functions.php file or a custom plugin.
The prompts
Prompt 1
Generate the PHP code to register an ACF field group named 'Product Details'. It should have the following fields:
1. A text field with the label 'Product Name' and the name 'product_name'.
2. A textarea field with the label 'Product Description' and the name 'product_description'.
3. A number field with the label 'Product Price' and the name 'product_price'. It should have a default value of 0.00 and allow decimals.
4. An image field with the label 'Product Image' and the name 'product_image'. Set the return format to 'Image URL'.
Include all necessary ACF functions and ensure the code is properly formatted and commented for easy understanding. The field group should appear on the 'product' post type edit screen.
1. A text field with the label 'Product Name' and the name 'product_name'.
2. A textarea field with the label 'Product Description' and the name 'product_description'.
3. A number field with the label 'Product Price' and the name 'product_price'. It should have a default value of 0.00 and allow decimals.
4. An image field with the label 'Product Image' and the name 'product_image'. Set the return format to 'Image URL'.
Include all necessary ACF functions and ensure the code is properly formatted and commented for easy understanding. The field group should appear on the 'product' post type edit screen.
Prompt 2
I need ACF field group code for a 'Homepage Settings' panel. This panel should contain:
1. A repeater field named 'homepage_slides' that allows adding multiple slides.
2. Within the repeater field, each slide should have:
* A text field named 'slide_title'.
* An image field named 'slide_image' (return format: 'Image ID').
* A URL field named 'slide_link'.
3. A WYSIWYG field named 'homepage_content'.
The field group should appear under the 'Options Page' and be named 'Homepage Options'. Use the acf_add_options_page() function to create the options page. Provide all necessary PHP code, properly commented, to implement this setup.
1. A repeater field named 'homepage_slides' that allows adding multiple slides.
2. Within the repeater field, each slide should have:
* A text field named 'slide_title'.
* An image field named 'slide_image' (return format: 'Image ID').
* A URL field named 'slide_link'.
3. A WYSIWYG field named 'homepage_content'.
The field group should appear under the 'Options Page' and be named 'Homepage Options'. Use the acf_add_options_page() function to create the options page. Provide all necessary PHP code, properly commented, to implement this setup.