The vast majority of Genesis themes support multiple layout options – such as sidebar on the left, sidebar on the right and no sidebar at all.
If you’re making a customization that relies on a certain site layout option, you’ll need a way to check which layout option is currently in use. Genesis provides an easy way for you to do this.
The function to use is
This function checks each of the different methods through which you can select a site layout option, and finally returns the ID of the layout option to be used. The Genesis Framework relies on this function to determine which site layout to load for each page.
You can use
genesis_site_layout to change design elements based on the layout that is in use. As an example, the below code removes the author and date from Posts and Pages with full width content and no sidebar.
$use_cache – whether to reuse the return value of a previous call to
genesis_site_layout (or, if it’s the first time the function’s been called, save the return value for the next call), instead of getting it fresh from the database and discarding at the end of the function. This is recommended, because it usually would not make sense for the site layout to change mid-page.
genesis_site_layout returns one of the following, in order from highest to lowest priority:
- the value entered into the filter
genesis_site_layout, if any
- the value returned when the function was called up previously, if the cache argument is true
- the custom layout for the current Post, Page or archive, if any
- the default layout as per Theme Settings.
The return values for the built in site layouts are:
There is one filter on the output of this function, which is
genesis_site_layout. This filter short circuits the function and can be used to override the settings and force a certain layout.
genesis_site_layout has been included since version 0.2.2.
genesis_site_layout is located in lib/functions/layout.php.