Featured Content

Last modified: November 26, 2025

link Block names

link Featured Content Post Templates

A featured content post template is made up of a list of blocks. Any block can be used in a template.

Here's an example of a template:

<!-- wp:t2/post-link -->
	<!-- wp:t2/post-featured-image /-->
	<!-- wp:group {"align":"full","layout":{"inherit":false}} -->
		<div class="wp-block-group alignfull">
			<!-- wp:t2/post-title /-->
		</div>
	<!-- /wp:group -->
<!-- /wp:t2/post-link -->

link Custom Templates

The default template can be customized by adding templates to a t2/featured-content folder in your theme. Templates should be structured like this:

theme
|-- style.css
|-- functions.php
|-- t2
    |-- featured-content
        |-- default.html
        |-- post-type-{my-post-type-name}.html

link Template Registration

Templates are automatically registered from your theme's t2/featured-content directory. You can also programmatically register templates:

use function T2\Blocks\FeaturedContent\register_featured_content_template;

register_featured_content_template( 'my-template', $template_html, $settings );

link Template Filters

You can override the template fetching logic:

add_filter( 't2/block/featured_content/pre_get_template', function( $override, $attributes, $context ) {
    // Return a template string to override
    return $custom_template;
}, 10, 3 );

link Template Examples

link JS

addFilter(
	'T2.FeaturedPost.template',
	'Theme.FeaturedPost.template',
	(template, postType, attributes, context, clientId) => {
		if (!!attributes.simplifiedPersonCard) {
			return window.t2FeaturedPostTemplates['post-type-person-simple-card'].template;
		}

		return template;
	}
);

link PHP

\T2\Blocks\FeaturedContent\register_featured_content_template(
	'post-type-person-simple-card',
	'<!-- wp:heading {"level":3} -->
		<h3 class="wp-block-heading">🔥 Alternative template</h3>
	<!-- /wp:heading -->
	<!-- wp:t2/post-title /-->'
);

/**
 * Load a alternative card template for the person block if we want the simplified layout.
 *
 * @param string $template Template.
 * @param array  $attributes Block attributes.
 */
function person_block_template( $template, array $attributes ) {
	if ( isset( $attributes['simplifiedPersonCard'] ) && $attributes['simplifiedPersonCard'] ) {
		$registry = \T2\Blocks\FeaturedContent\get_registry();
		$template = $registry->get( 'post-type-person-simple-card', false );

		if ( $template ) {
			return $template['template'];
		}
	}

	return $template;
}
\add_filter( 't2/block/featured_content/pre_get_template', __NAMESPACE__ . '\\person_block_template', 10, 2 );

link Post Classes

Featured content posts automatically receive CSS classes based on post type, taxonomies, and MIME type (for attachments). You can modify these classes:

add_filter( 't2/block/featured_content/post_classes', function( $classes, $post ) {
    $classes[] = 'my-custom-class';
    return $classes;
}, 10, 2 );

Applied classes include:

link Configuration

link Changing Allowed Inner Blocks

Changing the allowed blocks in the featured content layout can be done in t2.json. Return the names of blocks you want to allow.

Default: [t2/featured-query-post, t2/featured-single-post]

"t2/featured-content-layout": {
	"allowedBlocks": [
		"core/cover",
		"core/paragraph",
		"t2/featured-query-post",
		"t2/featured-single-post"
	]
}

link Changing Allowed Grid Sizes

Changing the allowed grid sizes in the featured content layout can be done in t2.json. Add a number array with allowed columns in a 12 grid system (e.g., 6 columns = 50%), or/and a number array of allowed rows.

Default columns: [4, 8, 12]
Default rows: [1, 2]

"t2/featured-content-layout": {
	"allowedColumns": [ 4, 6, 8, 12 ],
	"allowedRows": [ 1, 2, 3 ]
}

link Styles

link Column and Row Gap

{
	"settings": {
		"custom": {
			"t2/featuredContentLayout": {
				"spacing": {
					"columnGap": "1rem",
					"rowGap": "1rem"
				}
			}
		}
	}
}

link Single Block Gap

This needs to be a single value since it is used in calculations. This cannot be used as shorthand for column and row.

{
	"settings": {
		"custom": {
			"t2/featuredContentLayout": {
				"spacing": {
					"gap": "1rem"
				}
			}
		}
	}
}

link Properties (t2.json)

link Hooks

link blocks/src/featured-content/index.php

Short-circuit the template-fetching logic if a value is returned.

apply_filters( 't2/block/featured_content/pre_get_template', string|null $override, array $attributes, array $context )
Parameter Type Description
$override string|null Template override to return. Default null.
$attributes array Block attributes passed to the block.
$context array Block context.

T2 Featured Content Post Classes.
This filter allows you to modify the classes applied to the featured content post.

apply_filters( 't2/block/featured_content/post_classes', array $classes, \WP_Post $post )
Parameter Type Description
$classes array Array of classes to apply to the post.
$post \WP_Post The post object.