How to embed/include Carbon Fields in a theme
-
I don’t want to use Carbon Fields as a plugin. I want to include it in my theme. CF’s Getting Started guide doesn’t cover it! So I explored my way:
I’ve downloaded the plugin (version 1.0), and extracted it. In my theme I placed the folder is in here:
my-theme/libs/carbon-fields/
Now in my
functions.php
, I put the following:function carbon_fields_spl_autoload_register( $class ) { if ( stripos( $class, 'Carbon_Fields') === false ) { return; } $file_path = get_template_directory() . '/core/' . str_ireplace( 'Carbon_Fields\\', '', $class ) . '.php'; $file_path = str_replace( '\\', DIRECTORY_SEPARATOR, $file_path ); include_once( $file_path ); } spl_autoload_register( 'carbon_fields_spl_autoload_register' ); include_once get_template_directory() .'/libs/carbon-fields/carbon-fields.php'; include_once get_template_directory() .'/libs/carbon-fields/core/functions.php';
But it’s not working and showing me warnings, and a Fatal Error:
Fatal error: Class ‘Carbon_Fields\Helper\Helper’ not found
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to embed/include Carbon Fields in a theme’ is closed to new replies.