Skip to content

Snippet: Alter Post Types Grid Module Read More Text Based on Post Type

This snippet will allow you to alter the readmore text in the post types grid module loop so you can display different text based on the current post type. You can also make sue of the vcex_shortcode_loop_atts to alter various other attributes simply use print_r( $atts ) inside the function to see what else is available.

add_filter( 'vcex_shortcode_loop_atts', function( $atts, $shortcode ) {
	if ( 'vcex_post_type_grid' == $shortcode ) {
		$post_type = get_post_type();
		if ( 'portfolio' == $post_type ) {
			$atts['read_more_text'] = 'view project';
		} elseif ( 'post' == $post_type ) {
			$atts['read_more_text'] = 'read article';
	return $atts;
}, 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