If you’re having issues initializing Custom Field Suite (CFS) fields in WordPress, one solution is to use the get_fields
function from the Advanced Custom Fields (ACF) plugin. To get the CFS field value in the get_page_by_path
function, you can use the following code:
code$page = get_page_by_path('page-slug');
$fields = get_fields($page->ID);
$field_value = $fields['field_name'];
Replace 'page-slug'
with the actual slug of the page you want to retrieve, and 'field_name'
with the actual name of the CFS field you want to retrieve.
Note: The get_fields
function requires the ACF plugin to be installed and activated in your WordPress site.
Last modified: March 3, 2023