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


/ Published in: CSS
Save to your folder(s)

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 and 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.


Copy this code and paste it in your HTML
  1. function custom_body_classes($classes) {
  2. $classes[] = "landing-page";
  3.  
  4. return $classes;
  5. }
  6.  
  7. function custom_remove_defaults($content) {
  8. return false;
  9. }
  10.  
  11. register_sidebars(2,
  12. array(
  13. 'name' => 'Landing Page %d',
  14. 'id' => 'landing-page-$i',
  15. 'before_widget' => '<li class="widget %2$s" id="%1$s">',
  16. 'after_widget' => '</li>',
  17. 'before_title' => '<h3>',
  18. 'after_title' => '</h3>'
  19. )
  20. );
  21.  
  22. function landing_page_sidebar() {
  23. ?>
  24. </div> <!-- custom end #content -->
  25. <div id="sidebars">
  26. <div id="sidebar_1" class="sidebar">
  27. <ul class="sidebar_list">
  28. <?php thesis_default_widget('landing-page-1'); ?>
  29. </ul>
  30. </div>
  31. <div id="sidebar_2" class="sidebar">
  32. <ul class="sidebar_list">
  33. <?php thesis_default_widget('landing-page-2'); ?>
  34. </ul>
  35. </div>
  36. </div>
  37. <div> <!-- balance out #content divs -->
  38. <?php
  39. }
  40.  
  41. function apply_custom_filters() {
  42. global $wp_query;
  43. $landing = get_post_meta($wp_query->post->ID, 'landing-page', true);
  44. if ($landing) {
  45. // remove unwanted sections
  46. add_filter('thesis_show_header', 'custom_remove_defaults');
  47. add_filter('thesis_show_sidebars', 'custom_remove_defaults');
  48. add_filter('thesis_show_footer', 'custom_remove_defaults');
  49. //add custom body class
  50. add_filter('thesis_body_classes','custom_body_classes');
  51. // add new sidebars
  52. add_action('thesis_hook_after_content','landing_page_sidebar');
  53. }
  54. }
  55. add_action('template_redirect','apply_custom_filters');
  56.  
  57. /*
  58.  
  59. Remove this for one sidebar only
  60.  
  61. <div id="sidebar_2" class="sidebar">
  62. <ul class="sidebar_list">
  63. <?php thesis_default_widget('landing-page-2'); ?>
  64. </ul>
  65. </div>
  66.  
  67. */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.