Skip to content

Snippet: Tweak the Post Types Grid Element Output

The theme now has filters added to each section of a grid making it easier to add content before/after it. This method still works but it's not as efficient. Have a look at the new snippet example here. Additionally, rather then modifying the Post Cards element you should use the new Post Cards element and choose from a preset card style or create your own custom card!

This snippet shows how you can modify the output of any "block" or "section" of the Post Types Grid element. So for example if you want you could override the default featured image display ("media" section) with your own custom code.

 * Tweak the Post Types Grid element output.
 * The function takes in the "blocks" which is an array of the different sections which include: media, title, date, categories, excerpt, read_more
 * The attributes variable returns all the settings from the element, for example if you are targeting a specific grid on the site you can give it a Unique ID and check for it using if ( 'my-unique-id' == $atts['unique_id'] )
 * @link
add_filter( 'vcex_post_type_grid_entry_blocks', function( $blocks, $atts ) {

	// Override entry media.
	$blocks['media'] = function() {
		return 'Your custom media output - this will replace the default image with your custom output';

	// Add new section after the title.
	$blocks = wpex_array_insert_after( 'title', $blocks, array(
		'custom_block' => function() {
			return 'my custom block output';
	) );

	return $blocks;
}, 10, 2 );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top