Код: Выделить всё
function register_custom_patterns() {
register_block_pattern(
'twentytwentyfive/asif', // The pattern slug
array(
'title' => __( 'Test Pattern', 'twentytwentyfive' ),
'description' => __( 'A custom test pattern for the theme.', 'twentytwentyfive' ),
'content' => file_get_contents( get_template_directory_uri() . '/patterns/asif.php'), // Path to your custom PHP file
)
);
}
add_action( 'init', 'register_custom_patterns' );
C:\xampp\htdocs\asif_wp\wp-content\themes\twentytwentyfive\patterns\asif.php
код asif.php
Код: Выделить всё
function asif() {
echo "Working!";
}
add_action( 'init', 'asif' );
Ошибка:
Код: Выделить всё
Fatal error: Uncaught Error: Call to undefined function add_action() in C:\xampp\htdocs\asif_wp\wp-content\themes\twentytwentyfive\patterns\asif.php:6
Stack trace:
#0 {main}
thrown in C:\xampp\htdocs\asif_wp\wp-content\themes\twentytwentyfive\patterns\asif.php on line 6
Код: Выделить всё
Браузер загружается (ожидает) и проходит бесконечный цикл, и в конце мой компьютер зависает.
Подробнее здесь: https://stackoverflow.com/questions/792 ... rns-folder
Мобильная версия