When scaffolded for child theme, block's files are pointing to parent theme with get_template_directory() and get_template_directory_uri() functions.
Replicate
create and activate child theme
run scaffold command for block in theme
include block's php file in functions.php
try to add block in post or page
Expected outcome
After including block's php file in functions.php, I expect to have newly created block available on edit post/page screen, without errors.
Let us know what environment you are running this on
OS: Linux 5.0.0-35-generic #38-Ubuntu SMP Sat Nov 9 17:51:58 UTC 2019 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.2
PHP version: 7.2.24-0ubuntu0.19.04.1
php.ini used: /etc/php/7.2/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /home/milana
WP-CLI packages dir: /home/milana/.wp-cli/packages/
WP-CLI global config: /home/milana/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.4.0
Provide a possible solution
Replacing get_template_directory() and get_template_directory_uri() functions with get_stylesheet_directory() and get_stylesheet_directory_uri() respectively will work for both, standalone or child theme.
Bug Report
Current behavior
When scaffolded for child theme, block's files are pointing to parent theme with
get_template_directory()
andget_template_directory_uri()
functions.Replicate
functions.php
Expected outcome
After including block's php file in
functions.php
, I expect to have newly created block available on edit post/page screen, without errors.Let us know what environment you are running this on
Provide a possible solution
Replacing
get_template_directory()
andget_template_directory_uri()
functions withget_stylesheet_directory()
andget_stylesheet_directory_uri()
respectively will work for both, standalone or child theme.