You appear to be a bot. Output may be restricted
Description
Return all registered Genesis layouts.
Usage
$array = genesis_get_layouts( $type );
Parameters
- $type
- ( array|string ) optional default: site – Layout type to return. Leave empty to return default layouts. For arrays, types are checked from right to left, returning the first type with registered layouts and falling back to 'site' if no passed types have registered layouts. If the final array value is numeric, the second value from the end is assumed to be a post type, such as 'post' or 'page' and the layout specific to that page or post ID would be registered as 'post-123' or 'page-123'.
- Example 1, default layouts:
genesis_get_layouts();
- Example 2, 'page-123', 'page', 'singular', then 'site':
`genesis_get_layouts( [ 'singular', get_post_type(), get_the_ID() ] );`.
- Example 1, default layouts:
Returns
array Registered layouts.
Source
File name: genesis/lib/functions/layout.php
Lines:
1 to 49 of 49
function genesis_get_layouts( $type = 'site' ) { global $_genesis_layouts; // If no layouts exists, return empty array. if ( ! is_array( $_genesis_layouts ) ) { $_genesis_layouts = []; return $_genesis_layouts; } $layouts = []; $types = array_reverse( (array) $type ); // Default fallback is site. $types[] = 'site'; if ( is_numeric( $types[0] ) ) { $id = $types[0]; $types[0] = $types[1] . '-' . $types[0]; } // Cycle through looking for layouts of $type. foreach ( $types as $type ) { foreach ( $_genesis_layouts as $id => $data ) { if ( in_array( $type, $data['type'], true ) ) { $layouts[ $id ] = $data; } } if ( $layouts ) { break; } } /** * Filter the layouts array. * * Allows developer to filter the array of layouts returned. * * @since 2.5.0 * * @param array $layouts Layout data. * @param string $type Layout type. */ $layouts = (array) apply_filters( 'genesis_get_layouts', $layouts, $type ); return $layouts; }