Replace layout in RocketTheme themes (use the Gantry framework)

The Replace Layout feature of Content Views Pro doesn’t work automatically with RocketTheme themes (which use the Gantry framework).

To replace layout of archive pages (category, tag, taxonomy, author) and search results page in RocketTheme themes, please add this code to file functions.php in the theme’s folder:

// Content Views Pro - replace layout of archive pages, search results page
add_filter( 'timber_compile_result', 'cvp_theme_replace_archive_layout' );
function cvp_theme_replace_archive_layout( $args ) {
	if ( (is_search() || is_archive()) && shortcode_exists( 'pt_view' ) ) :
		$pids = array();
		foreach ( Timber::get_posts() as $post ) {
			$pids[] = $post->ID;
		}
		$view = do_shortcode( '[pt_view id="VIEW_ID" post_id="' . implode( ',', $pids ) . '"]' );

		$html	 = '<section class="entries">' . $view;
		$args	 = preg_replace( '/<section\sclass="entries".*<\/article>/s', $html, $args );
	endif;

	return $args;
}

Please replace VIEW_ID with ID of the View (which you want to use to replace layout of pages).

Notice: When replacing layout of RocketTheme themes, the Filter Settings and Pagination setting of the View will NOT be supported.

Scroll to Top