Return to Snippet

Revision: 42342
at March 3, 2011 14:27 by zachbrowne


Initial Code
function custom_body_classes($classes) {
	$classes[] = "landing-page";

	return $classes;
}

function custom_remove_defaults($content) {
        return false;
}

register_sidebars(2,
    array(
        'name' => 'Landing Page %d',
        'id' => 'landing-page-$i',
        'before_widget' => '<li class="widget %2$s" id="%1$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

function landing_page_sidebar() {
?>
</div> <!-- custom end #content -->
<div id="sidebars">
	<div id="sidebar_1" class="sidebar">
		<ul class="sidebar_list">
			<?php thesis_default_widget('landing-page-1'); ?>
		</ul>
	</div>
	<div id="sidebar_2" class="sidebar">
		<ul class="sidebar_list">
			<?php thesis_default_widget('landing-page-2'); ?>
		</ul>
	</div>
</div>
<div> <!-- balance out #content divs -->
<?php
}

function apply_custom_filters() {
	global $wp_query;
	$landing = get_post_meta($wp_query->post->ID, 'landing-page', true);
	if ($landing) {
		// remove unwanted sections
		add_filter('thesis_show_header', 'custom_remove_defaults');
		add_filter('thesis_show_sidebars', 'custom_remove_defaults');
		add_filter('thesis_show_footer', 'custom_remove_defaults');
		//add custom body class
		add_filter('thesis_body_classes','custom_body_classes');
		// add new sidebars
		add_action('thesis_hook_after_content','landing_page_sidebar');
	}
}
add_action('template_redirect','apply_custom_filters');

/*

Remove this for one sidebar only 

<div id="sidebar_2" class="sidebar">
		<ul class="sidebar_list">
			<?php thesis_default_widget('landing-page-2'); ?>
		</ul>
	</div>

*/

Initial URL


Initial Description
The following code for a landing page — without header, original sidebars and footer and with new sidebars added — goes in custom_functions.php. This code does the following to pages with a custom field named “landing-page”.

adds a body class of “landing-page”
removes the header, sidebars, and footer
registers 2 new sidebars called Landing Page 1 and Lading Page 2
builds the code for the new sidebars (note that an extra </div> and <div> are added because there’s no hook in between the end of #content and the end of #content_box)
then implements all of the above before Thesis loads. If you want a sidebar | content | sidebar arrangement, you’ll need different markup.

Initial Title
Add Squeeze Page to Thesis Theme for WordPress With Custom Filter for Thesis 1.8 With Different Sidebars

Initial Tags
php, wordpress

Initial Language
CSS