Este código funciona bien:
function register_custom_patterns() {
$vari = 5;
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?id='. $vari), // Path to your custom PHP file
)
);
}
add_action( 'init', 'register_custom_patterns' );
Pero no funciona:
function register_custom_patterns() {
$vari = "Send me";
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?id='. $vari), // Path to your custom PHP file
)
);
}
add_action( 'init', 'register_custom_patterns' );
Error:
http://localhost/asif_wp/wp-content/themes/twentytwentyfive/patterns/asif.php?id=Send me): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\xampp\htdocs\asif_wp\wp-content\themes\twentytwentyfive\functions.php on line 168
En breve:
Parámetro
$vari = 5; // Working
$vari = "Show me"; //Error
¿Por qué y cómo solucionarlo?