The other day, I was creating a page template using the standard approach used in forcing a specific layout. However, when using page templates, this will work if they have not selected a specific layout on the page in the Genesis Layouts metabox. So you could either hide the Genesis metabox, or you can have the page template ignore any changes made in the layout metabox (less coding!).
The normal procedure is as follows:
[php]
add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content');
[/php]
However, this ignores any custom fields that may upset this. So since this is pre_get_option_*, the user can accidentally over-ride the "forced" specific layout. So if you don't want the user to over-ride it you need to go a step further. You can add one more line of code to correct and ensure that a page can never have a different layout. One way is to set the post meta to always be whatever you want.
[php]
global $post;
// Force Page Layout for Page Template
update_post_meta( $post->ID, '_genesis_layout', 'full-width-content' );
[/php]
However, the Genesis approach would be to set it via the pre site layout Filter.
GaryJ says
The code in the first part can be simplified down to just the add_filter line, using the __genesis_return_full_width_content (added in G 1.7) as the callback.
For consistency, the last argument in the second block of code could be replaced with a straight call to the same function:
update_post_meta( $post->ID, '_genesis_layout', __genesis_return_full_width_content() );
It’s slightly longer, but it’s sweeter to use a function than a string, should Genesis ever change the name of the full width layout.
Brad Dalton says
Travis
Can this be used in a custom function with a conditional tag for a specific page i.d?