为WordPress的论文主题添加压缩页面,并为论文1.8添加自定义过滤器,使其具有不同的侧面

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为WordPress的论文主题添加压缩页面,并为论文1.8添加自定义过滤器,使其具有不同的侧面相关的知识,希望对你有一定的参考价值。

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.
  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. */

以上是关于为WordPress的论文主题添加压缩页面,并为论文1.8添加自定义过滤器,使其具有不同的侧面的主要内容,如果未能解决你的问题,请参考以下文章

为WordPress的论文主题添加压缩页面,并使用论文1.8的自定义过滤器

为WordPress的论文主题添加多个压缩页面,并使用论文1.8的自定义过滤器

如何在wordpress主题中添加设置页面

使用 Sass 压缩输出,同时为 Wordpress 保留主题注释标题

wordpress怎么自己创建主题和设置主题

wordpress怎么自己创建主题和设置主题