I’m using ACF Blocks and the block I’ve built shows in the back end and the front end! Yaay!
However, some inline styles of created within the block template file are, for some reason, not displaying. The style
rules do not show up for the block below. However, I do have another block that I built where the style rules DO show. Head scratcher. Not sure what I’m doing wrong.
<?php
/**
* Block template file: /app/wp-content/mu-plugins/custom-functionality/blocks/inc/../views/block-heading-w-icon.php
*
* Heading With Icon Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/
// Create id attribute allowing for custom "anchor" value.
$id = 'heading-with-icon-' . $block['id'];
if ( ! empty( $block['anchor'] ) ) {
$id = $block['anchor'];
}
$hl = get_field( 'hwi_heading_level' );
$hwi_icon = get_field( 'hwi_icon' );
$font_size = get_field( 'hwi_font_size' );
$hwi_position = get_field( 'hwi_icon_position' );
// Create class attribute allowing for custom "className" and "align" values.
$classes = 'block-heading-with-icon';
if ( ! empty( $block['className'] ) ) {
$classes .= ' ' . $block['className'];
}
if ( ! empty( $block['align'] ) ) {
$classes .= ' align' . $block['align'];
}
?>
<style type="text/css">
/* help */
</style>
<div id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
<<?php echo $hl; ?> id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $classes ); ?>"><?php the_field( 'hwi_heading_text' ); ?></<?php echo $hl; ?>>
<?php $hwi_icon = get_field( 'hwi_icon' ); ?>
<?php if ( $hwi_icon ) { ?>
<img src="<?php echo $hwi_icon['url']; ?>" alt="<?php echo $hwi_icon['alt']; ?>" id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $classes ); ?>"/>
<?php } ?>
</div>
<code></code>