为twentythirteen子主题添加pagenavi分页导航

为twentythirteen子主题添加pagenavi分页导航:方法同为twentytwelve子主题添加pagenavi分页导航一样,修改function.php文件即可,添加一段代码即可实现。

twentythirteen主题是暖色系,是WordPress 3.6的默认主题。利用twentythirteen主题修改的子主题。

twentythirteen主题和twentytwelve一样,分页导航也不咋的。

如何修改twentythirteen子主题的function.php实现pagenavi,我的方法如下。

修改function.php


打开子主题的function.php,添加如下代码:



  1. /**

  2. * Display new navigation to next/previous pages when applicable

  3. */

  4. function twentythirteen_paging_nav() {

  5. global $wp_query;

  6. if ( $wp_query->max_num_pages > 1 ) : ?>

  7. <?php

  8. /**

  9. Call our new function to see if any pagination plugins are active

  10. If one of the plugins is active then exit this function

  11. If none of the plugins are active use the default styles

  12. */

  13. ?>

  14. <?php /* Is the Pagenavi plugin active ? */ ?>

  15. <?php if( function_exists('wp_pagenavi') ) : ?>

  16. <?php wp_pagenavi(); ?>

  17. <?php return true; //Get out of here! ?>

  18. <?php endif; ?>

  19. <?php endif;

  20. }

  21. endif// twentythirteen_paging_nav



同样,如果子主题的function.php未添加其它任何代码,前面要加<?php

美化pagenavi分页导航


在twentythirteen子主题添加如下代码即可



  1. /* Using !important to override PageNavi CSS */

  2. .wp-pagenavi {

  3. background-color#e8e5ce;

  4. padding:18px;

  5. }

  6. .wp-pagenavi a, .wp-pagenavi a:link, .wp-pagenavi span {

  7. color:#444!important;

  8. font-style:normal;

  9. margin:7px !important;

  10. padding:7px !important;

  11. border-radius: 7px;

  12. -moz-border-radius: 7px;

  13. -webkit-border-radius: 7px;

  14. }

  15. .wp-pagenavi a:visited {

  16. border:1px solid #ccc !important;

  17. color:#666 !important;

  18. }

  19. .wp-pagenavi a:hover {

  20. border:1px solid #4285F4 !important;

  21. color:#666 !important;

  22. }

  23. .wp-pagenavi a:active {

  24. border:1px solid #666 !important;

  25. color:#666 !important;

  26. }

  27. .wp-pagenavi span.pages {

  28. displaynone;

  29. }

  30. .wp-pagenavi span.current {

  31. background#42A2CE !important;

  32. bordernone !important;

  33. color:#fff!important;

  34. font-style:normal;

  35. margin:7px !important;

  36. padding:7px !important;

  37. border-radius: 7px;

  38. -moz-border-radius: 7px;

  39. -webkit-border-radius: 7px;

  40. }

  41. .wp-pagenavi span.extend {

  42. background-color:#FFF;

  43. border:1px solid #42A2CE;

  44. color:#000;

  45. margin:2px;

  46. padding:2px 4px;

  47. }



为了和原twentythirteen主题的导航一致,添加了一个背景。

评论

此博客中的热门博文

Word2007或2010未显示EndNote工具条的解决方法

EndNote X8 汉化版

推荐25个搜索下载电子书籍的好地方

EndNote为参考文献分类显示

EndNote插入引文时只有作者和发表年代及数字无参考文献,如Dayan, 2013 #34的 原因和解决方法