添加微语页面

综合评论8,548,974字数 1109阅读3分41秒
美化教程

1、首先在子比主题目录的functions.php里面加入以下代码:

复制代码
  1. //微语
  2. add_action('init', 'my_custom_init'); function my_custom_init() { $labels = array( 'name' => '微语', 'singular_name' => 'singularname', 'add_new' => '发表微语', 'add_new_item' => '发表微语', 'edit_item' => '编辑微语', 'new_item' => '新微语', 'view_item' => '查看微语', 'search_items' => '搜索微语', 'not_found' => '暂无微语', 'not_found_in_trash' => '没有已遗弃的微语', 'parent_item_colon' => '', 'menu_name' => '微语' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author') ); register_post_type('shuoshuo',$args); }

2、然后在子比主题pages目录下新建一个weiyu.php文件,然后把下面代码放入weiyu.php文件中即可。文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html

复制代码
  1. <?php
  2. /**
  3. * Template name: 微语页面
  4. * Description: weiyu
  5. */
  6. // 获取链接列表
  7. get_header();
  8. $header_style = zib_get_page_header_style();
  9. ?>
  10. <main class="container">
  11. <div class="content-wrap">
  12. <div class="content-layout">
  13. <?php while (have_posts()) : the_post(); ?>
  14. <?php if ($header_style != 1) {
  15. echo zib_get_page_header();
  16. } ?>
  17. <?php endwhile; ?>
  18. <div class="box-body theme-box radius8 main-bg main-shadow">
  19. <?php if ($header_style == 1) {
  20. echo zib_get_page_header();
  21. } ?>
  22. <!--主体开始-->
  23. <style type="text/css">
  24. #shuoshuo_content{padding: 10px; /*min-height: 500px;*/} /* shuo */ body.theme-dark .cbp_tmtimeline::before{background: RGBA(255, 255, 255, 0.06);} ul.cbp_tmtimeline{padding: 0;} div class.cdp_tmlabel > li .cbp_tmlabel{margin-bottom: 0;} .cbp_tmtimeline{margin: 30px 0 0 0; padding: 0; list-style: none; position: relative;} /* The line */ .cbp_tmtimeline:before{/*content: '';*/ position: absolute; top: 0; bottom: 0; width: 4px; background: RGBA(0, 0, 0, 0.02); left: 80px; margin-left: 10px;} /* The date/time */ .cbp_tmtimeline > li .cbp_tmtime{display: block; /* width: 29%; */ /* padding-right: 110px; */ max-width: 70px; position: absolute;} .cbp_tmtimeline > li .cbp_tmtime span{display: block; text-align: right;} .cbp_tmtimeline > li .cbp_tmtime span:first-child{font-size: 0.9em; color: #bdd0db;} .cbp_tmtimeline > li .cbp_tmtime span:last-child{font-size: 1.2em; color: #9BCD9B;} .cbp_tmtimeline > li:nth-child(odd) .cbp_tmtime span:last-child{color: RGBA(255, 125, 73, 0.75);} div.cbp_tmlabel > p{margin-bottom: 0;} /* Right content */ .cbp_tmtimeline > li .cbp_tmlabel{margin: 0 0 45px 65px; background: #9BCD9B; color: #fff; padding: .8em 1.2em .4em 1.2em; /* font-size: 1.2em; */ font-weight: 300; line-height: 1.4; position: relative; border-radius: 5px; transition: all 0.3s ease 0s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); cursor: pointer; display: block;} .cbp_tmlabel:hover{transform:scale(1.05); transform: translateY(-3px); z-index: 1; -webkit-box-shadow: 0 15px 32px rgba(0, 0, 0, 0.15) !important} .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel{background: RGBA(255, 125, 73, 0.75);} /* The triangle */ .cbp_tmtimeline > li .cbp_tmlabel:after{right: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-right-color: #9BCD9B; border-width: 10px; top: 4px;} .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel:after{border-right-color: RGBA(255, 125, 73, 0.75);} p.shuoshuo_time{margin-top: 10px; border-top: 1px dashed #fff; padding-top: 5px;} /* Media */ @media screen and (max-width: 65.375em){.cbp_tmtimeline > li .cbp_tmtime span:last-child{font-size: 1.2em;} } .shuoshuo_author_img img{border: 1px solid #ddd; padding: 2px; float: left; border-radius: 64px; transition: all 1.0s;} .avatar{-webkit-border-radius: 100% !important; -moz-border-radius: 100% !important; box-shadow: inset 0 -1px 0 #3333sf; -webkit-box-shadow: inset 0 -1px 0 #3333sf; -webkit-transition: 0.4s; -webkit-transition: -webkit-transform 0.4s ease-out; transition: transform 0.4s ease-out; -moz-transition: -moz-transform 0.4s ease-out;} .zhuan{transform: rotateZ(720deg); -webkit-transform: rotateZ(720deg); -moz-transform: rotateZ(720deg);}
  25. </style>
  26. </head>
  27. <body>
  28. <div id="primary" class="content-area" style="">
  29. <main id="main" class="site-main" role="main">
  30. <div id="shuoshuo_content">
  31. <ul class="cbp_tmtimeline">
  32. <?php query_posts("post_type=shuoshuo&post_status=publish&posts_per_page=-1");if (have_posts()) : while (have_posts()) : the_post(); ?>
  33. <li> <span class="shuoshuo_author_img"><img src="https://q1.qlogo.cn/g?b=qq&nk=86512&s=640" class="avatar avatar-48" style="width:48px;height:48px"></span>
  34. <a class="cbp_tmlabel" href="javascript:void(0)">
  35. <h4><?php the_title(); ?></h4>
  36. <p><?php the_content(); ?></p>
  37. <p></p>
  38. <p class="shuoshuo_time"><i class="fa fa-clock-o"></i>
  39. <?php the_time('Y年n月j日G:i'); ?>
  40. </p>
  41. </a>
  42. <?php endwhile;endif; ?>
  43. </li>
  44. </ul>
  45. </div>
  46. </main>
  47. </div>
  48. <script type="text/javascript">
  49. $(function () {
  50. var oldClass = "";
  51. var Obj = "";
  52. $(".cbp_tmtimeline li").hover(function () {
  53. Obj = $(this).children(".shuoshuo_author_img");
  54. Obj = Obj.children("img");
  55. oldClass = Obj.attr("class");
  56. var newClass = oldClass + " zhuan";
  57. Obj.attr("class", newClass);
  58. }, function () {
  59. Obj.attr("class", oldClass);
  60. })
  61. })
  62. </script>
  63. <!--主体结束-->
  64. </div>
  65. <?php comments_template('/template/comments.php', true); ?>
  66. </div>
  67. </div>
  68. <?php get_sidebar(); ?>
  69. </main>
  70. <?php
  71. get_footer();

注:微语头像只需把代码中”https://q1.qlogo.cn/g?b=qq&nk=86512&s=640″修改成自己QQ号头像或者自己图片链接即可。文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html

3、最后在后台—>页面—>新建页面—>找到“页面属性”选择“微语页面”—>填写标题—>发布就可以啦!文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html

发表微语文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html

发表微语只需在后台—>微语—>发表微语,然后发表自己喜欢的微语即可。文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html

说明:因为微语页面采用主题添加代码的方式生成的页面,主题更新后会失效,所以更新主题时请及时备份文件代码,或者关注收藏本站。好啦!子比主题添加微语页面的文章教程到这里就结束了!文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html

文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/565.html
继续阅读
分页按钮美化
分页按钮美化 综合

分页按钮美化

/*页码样式微调*/ .pagenav .current, .pagenav .page-numbers, .pagenav a { border: 0; padding: 8px 14px; bac...
  • 本文由 admin 发表于2024年8月10日 15:41:05
  • 转载请务必保留本文链接:https://bbs.50-0.cn/565.html
匿名

发表评论

匿名网友
确定