Answer the question
In order to leave comments, you need to log in
Why doesn't the "carbon_fields_register_fields" hook work?
Installed the Carbon Fields plugin.
I registered insurance in the functions.php file
if ( ! function_exists( 'carbon_get_post_meta' ) ) {
function carbon_get_post_meta( $id, $name, $type = null ) {
return false;
}
}
add_action( 'carbon_fields_register_fields', 'crb_attach_post_options' );
function crb_attach_post_options() {
// путь к пользовательскому файлу определения поля (полей), измените под себя
require_once __DIR__ . '/inc/carbon-fields/home-fields.php';
}
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Container::make( 'post_meta', 'Текст слайдера' )
->show_on_post_type('page') // этот метод можно не писать, так как show_on_post_type('post') по умолчанию
->show_on_page('glavnaya')
->add_fields(array(
Field::make('text', 'home_slider_text_1', 'Текст слайдера')
->set_width(33),
Field::make('text', 'home_slider_text_2', 'Текст слайдера')
->set_width(33),
Field::make('text', 'home_slider_text_3', 'Текст слайдера')
->set_width(33)
));
require_once __DIR__ . '/inc/carbon-fields/home-fields.php';
Answer the question
In order to leave comments, you need to log in
Hello. Classic mistake. You appear to be using the carbon_fields_register_fields hook , but are running CF 1.6. This hook appeared in CF v 2.0. Version 1.6 had the carbon_register_fields hook .
From my own advice, download CF 2.2 as a plugin and install it, since you are just getting started. There is nothing to loose. Version 1.6 is no longer developed, it does not have much that is in 2.2.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question