Skip to content

Snippet: Change Related Portfolio Columns for Mobile

/**
 * Add responsive grid classes to related portfolio entries
 * Note: Only add the classes you need. For example if the default columns
 * are set to 3 no need to define 3 columns again for tablet devices.
 *
 * All responsive column classes use the format span_1_of_{columns}_{device}
 * Devices: tl => tablet landscape
 *			tp => tablet portrait
 *			pl => phone landscape
 *			pp => phone portrait
 *
 */
add_filter( 'post_class', function( $classes ) {
	if ( is_singular( 'portfolio' ) && in_array( 'loop-related', $classes ) ) {
		$classes[] = 'span_1_of_2_tl'; // Set related portfolio items to 2 columns for tablet and under
	}
	return $classes;
} );
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