<address id="vxdjz"></address>

    <address id="vxdjz"></address>
    <form id="vxdjz"></form>

    <noframes id="vxdjz">

    http://www.nbkh.net.cn

    怎么給wordpress增加說說/微博功能

    作為一個個人的獨立博客,說說怎么少得了,有時候我們寫日志記心靜,或者做通告,長不長,短不短的話語總是糾結怎么寫成文章,但是為了人性化,像qq空間的說說,emlog的微語以及微博,都是把短語發揮到了極致,無奈wordpress沒有這項功能,今天西安SEO就給大家說說“怎么給wordpress增加說說/微博功能”。

    怎么給wordpress增加說說/微博功能

    樣式一:

    首先在主題的functions.php里面加入以下代碼:

    1. //說說功能?
    2. add_action('init',?'my_custom_init');
    3. function?my_custom_init()
    4. {?$labels?=?array(?'name'?=>?'說說',
    5. 'singular_name'?=>?'說說',
    6. 'add_new'?=>?'發表說說',
    7. 'add_new_item'?=>?'發表說說',
    8. 'edit_item'?=>?'編輯說說',
    9. 'new_item'?=>?'新說說',
    10. 'view_item'?=>?'查看說說',
    11. 'search_items'?=>?'搜索說說',
    12. 'not_found'?=>?'暫無說說',
    13. 'not_found_in_trash'?=>?'沒有已遺棄的說說',
    14. 'parent_item_colon'?=>?'',?'menu_name'?=>?'說說'?);
    15. $args?=?array(?'labels'?=>?$labels,
    16. 'public'?=>?true,
    17. 'publicly_queryable'?=>?true,
    18. 'show_ui'?=>?true,
    19. 'show_in_menu'?=>?true,
    20. 'exclude_from_search'?=>true,
    21. 'query_var'?=>?true,
    22. 'rewrite'?=>?true,?'capability_type'?=>?'post',
    23. 'has_archive'?=>?false,?'hierarchical'?=>?false,
    24. 'menu_position'?=>?null,?'supports'?=>?array('editor','author','title',?'custom-fields')?);
    25. register_post_type('shuoshuo',$args);
    26. }

    其次,把下方代碼保存為一shuoshuo.php文件上傳到你正在使用的主題根目錄里。

    1. <?php?/*
    2. ????Template?Name:?說說頁面
    3. ????author:?沃森博客
    4. ????本文教程:http://wosn.net/540.html
    5. ????*/
    6. ????get_header();??>
    7. <style?type="text/css">
    8. ????#shuoshuo_content?{
    9. ????????background-color:?#fff;
    10. ????????padding:?10px;
    11. ????????min-height:?500px;
    12. ????????text-align:center;
    13. ????}
    14. ????/*?shuo?*/
    15. ????body.theme-dark?.cbp_tmtimeline::before?{
    16. ????????background:?RGBA(255,?255,?255,?0.06);
    17. ????}
    18. ????ul.cbp_tmtimeline?{
    19. ????????padding:?0;
    20. ????}
    21. ????div?class.cdp_tmlabel?>?li?.cbp_tmlabel?{
    22. ????????margin-bottom:?0;
    23. ????}
    24. ????.cbp_tmtimeline?{
    25. ????????margin:?30px?0?0?0;
    26. ????????padding:?0;
    27. ????????list-style:?none;
    28. ????????position:?relative;
    29. ????}
    30. ????/*?The?line?*/
    31. ????.cbp_tmtimeline:before?{
    32. ????????content:?'';
    33. ????????position:?absolute;
    34. ????????top:?0;
    35. ????????bottom:?0;
    36. ????????width:?4px;
    37. ????????background:?RGBA(0,?0,?0,?0.02);
    38. ????????left:?80px;
    39. ????????margin-left:?10px;
    40. ????}
    41. ????/*?The?date/time?*/
    42. ????.cbp_tmtimeline?>?li?.cbp_tmtime?{
    43. ????????display:?block;
    44. ????????/*?width:?29%;
    45. ????????padding-right:?110px;??*/
    46. ????????max-width:?70px;
    47. ????????position:?absolute;
    48. ????}
    49. ????.cbp_tmtimeline?>?li?.cbp_tmtime?span?{
    50. ????????display:?block;
    51. ????????text-align:?right;
    52. ????}
    53. ????.cbp_tmtimeline?>?li?.cbp_tmtime?span:first-child?{
    54. ????????font-size:?0.9em;
    55. ????????color:?#bdd0db;
    56. ????}
    57. ????.cbp_tmtimeline?>?li?.cbp_tmtime?span:last-child?{
    58. ????????font-size:?1.2em;
    59. ????????color:?#9BCD9B;
    60. ????}
    61. ????.cbp_tmtimeline?>?li:nth-child(odd)?.cbp_tmtime?span:last-child?{
    62. ????????color:?RGBA(255,?125,?73,?0.75);
    63. ????}
    64. ????div.cbp_tmlabel?>?p?{
    65. ????????margin-bottom:?0;
    66. ????}
    67. ????/*?Right?content?*/
    68. ????.cbp_tmtimeline?>?li?.cbp_tmlabel?{
    69. ????????margin:?0?0?45px?65px;
    70. ????????background:?#9BCD9B;
    71. ????????color:?#fff;
    72. ????????padding:?.8em?1.2em?.4em?1.2em;
    73. ????????/*?font-size:?1.2em;?*/
    74. ????????font-weight:?300;
    75. ????????line-height:?1.4;
    76. ????????position:?relative;
    77. ????????border-radius:?5px;
    78. ????????transition:?all?0.3s?ease?0s;
    79. ????????box-shadow:?0?1px?2px?rgba(0,?0,?0,?0.15);
    80. ????????cursor:?pointer;
    81. ????????display:?block;
    82. ????}
    83. ????.cbp_tmlabel:hover?{
    84. ????????/*?transform:scale(1.05);?*/
    85. ????????transform:?translateY(-3px);
    86. ????????z-index:?1;
    87. ????????-webkit-box-shadow:?0?15px?32px?rgba(0,?0,?0,?0.15)?!important
    88. ????}
    89. ????.cbp_tmtimeline?>?li:nth-child(odd)?.cbp_tmlabel?{
    90. ????????background:?RGBA(255,?125,?73,?0.75);
    91. ????}
    92. ????/*?The?triangle?*/
    93. ????.cbp_tmtimeline?>?li?.cbp_tmlabel:after?{
    94. ????????right:?100%;
    95. ????????border:?solid?transparent;
    96. ????????content:?"?";
    97. ????????height:?0;
    98. ????????width:?0;
    99. ????????position:?absolute;
    100. ????????pointer-events:?none;
    101. ????????border-right-color:?#9BCD9B;
    102. ????????border-width:?10px;
    103. ????????top:?4px;
    104. ????}
    105. ????.cbp_tmtimeline?>?li:nth-child(odd)?.cbp_tmlabel:after?{
    106. ????????border-right-color:?RGBA(255,?125,?73,?0.75);
    107. ????}
    108. ????p.shuoshuo_time?{
    109. ????????margin-top:?10px;
    110. ????????border-top:?1px?dashed?#fff;
    111. ????????padding-top:?5px;
    112. ????}
    113. ????/*?Media?*/
    114. ????@media?screen?and?(max-width:?65.375em)?{
    115. ????????.cbp_tmtimeline?>?li?.cbp_tmtime?span:last-child?{
    116. ????????????font-size:?1.2em;
    117. ????????}
    118. ????}
    119. ????.shuoshuo_author_img?img?{
    120. ????????border:?1px?solid?#ddd;
    121. ????????padding:?2px;
    122. ????????float:?left;
    123. ????????border-radius:?64px;
    124. ????????transition:?all?1.0s;
    125. ????}
    126. ????.avatar?{
    127. ????????-webkit-border-radius:?100%?!important;
    128. ????????-moz-border-radius:?100%?!important;
    129. ????????box-shadow:?inset?0?-1px?0?#3333sf;
    130. ????????-webkit-box-shadow:?inset?0?-1px?0?#3333sf;
    131. ????????-webkit-transition:?0.4s;
    132. ????????-webkit-transition:?-webkit-transform?0.4s?ease-out;
    133. ????????transition:?transform?0.4s?ease-out;
    134. ????????-moz-transition:?-moz-transform?0.4s?ease-out;
    135. ????}
    136. ????.zhuan?{
    137. ????????transform:?rotateZ(720deg);
    138. ????????-webkit-transform:?rotateZ(720deg);
    139. ????????-moz-transform:?rotateZ(720deg);
    140. ????}
    141. ????/*?end?*/
    142. </style>
    143. </head>
    144. <body>
    145. <div?id="primary"?class="content-area"?style="">
    146. ????<main?id="main"?class="site-main"?role="main">
    147. ????????<div?id="shuoshuo_content">
    148. ????????????<ul?class="cbp_tmtimeline">
    149. ????????????????<?php?query_posts("post_type=shuoshuo&post_status=publish&posts_per_page=-1");if?(have_posts())?:?while?(have_posts())?:?the_post();??>
    150. ????????????????<li>?<span?class="shuoshuo_author_img"><img?src="http://wosn.net/wp-content/themes/begin/img/touxiang/timg7.jpg"?class="avatar?avatar-48"?width="48"?height="48"></span>
    151. ????????????????????<a?class="cbp_tmlabel"?href="javascript:void(0)">
    152. ????????????????????????<p></p>
    153. ????????????????????????<p><?php?the_content();??></p>
    154. ????????????????????????<p></p>
    155. ????????????????????????<p?class="shuoshuo_time"><i?class="fa?fa-clock-o"></i>
    156. ????????????????????????????<?php?the_time('Y年n月j日G:i');??>
    157. ????????????????????????</p>
    158. ????????????????????</a>
    159. ????????????????????<?php?endwhile;endif;??>
    160. ????????????????</li>
    161. ????????????</ul>
    162. ????????</div>
    163. ????</main>
    164. ????<!--?.site-main?-->
    165. </div>
    166. <script?type="text/javascript">
    167. ????$(function?()?{
    168. ????????var?oldClass?=?"";
    169. ????????var?Obj?=?"";
    170. ????????$(".cbp_tmtimeline?li").hover(function?()?{
    171. ????????????Obj?=?$(this).children(".shuoshuo_author_img");
    172. ????????????Obj?=?Obj.children("img");
    173. ????????????oldClass?=?Obj.attr("class");
    174. ????????????var?newClass?=?oldClass?+?"?zhuan";
    175. ????????????Obj.attr("class",?newClass);
    176. ????????},?function?()?{
    177. ????????????Obj.attr("class",?oldClass);
    178. ????????})
    179. ????})
    180. </script>
    181. <?php?get_sidebar();??>
    182. <?php?get_footer();?>

    最后,打開后臺 → 頁面 → 新建頁面,標題處輸入“我的說說”,頁面模板處選擇我們的“說說頁面”,然后直接點擊發布頁面。你會發現后臺左側欄目出現了一個說說欄目,點擊它就可以發表說說了。

    效果請看:http://wosn.net/shuoshuo.html

    注意:在上方代碼(即說說頁面代碼)150行處,替換自己的頭像圖片。

    樣式二(未測試):

    操作方法同上,只是樣式不同。

    首先在主題的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);?}

    其次,把下方代碼保存為shuoshuo.php文件上傳到你正在使用的主題根目錄里。

    1. <?php?/*
    2. ???Template?Name:?說說頁面
    3. ???author:?沃森博客
    4. ???url:?http://wosn.net/540.html
    5. ???*/
    6. ???get_header();??><link href="shuoshuo.css" rel="stylesheet"><div?class="shuoshuo">
    7. ????<ul?class="archives-monthlisting">
    8. ????<?php?query_posts("post_type=shuoshuo&post_status=publish&posts_per_page=-1");if?(have_posts())?:?while?(have_posts())?:?the_post();??>
    9. ????<li><span?class="tt"><?php?the_time('Y年n月j日G:i');??></span>
    10. ????<div?class="shuoshuo-content"><?php?the_content();??><br/><div?class="shuoshuo-meta"><span?>—<?php?the_author()??></span></div></div><?php?endwhile;endif;??></li>
    11. ????</ul>
    12. ???</div>
    13. ???<?php?get_footer();?>

    把下方代碼保存為shuoshuo.css文件上傳到你正在使用的主題根目錄里。

    1. ?.shuoshuo?{
    2. positionrelative;
    3. margin50px?0;
    4. }
    5. .shuoshuo?li?{
    6. padding8px?0;
    7. displayblock;
    8. }
    9. .shuoshuo-content?{
    10. box-shadow:?0?0?3px?RGBA(0,0,0,.15);
    11. background-color#f8f8f8;
    12. border:1px?#eee?solid;
    13. border-radius:?4px;
    14. font-size:?1em;
    15. line-height:2.3em;
    16. margin:0?150px?0?200px;
    17. letter-spacing1px;
    18. padding20px?20px?5px?30px;
    19. color#666;
    20. min-height:60px;
    21. positionrelative;
    22. ?whitewhite-spacepre;?/*?CSS?2.0?*/
    23. ?whitewhite-spacepre-wrap;?/*?CSS?2.1?*/
    24. ?whitewhite-spacepre-line;?/*?CSS?3.0?*/
    25. ?whitewhite-space:?-pre-wrap;?/*?Opera?4-6?*/
    26. ?whitewhite-space:?-o-pre-wrap;?/*?Opera?7?*/
    27. ?whitewhite-space:?-moz-pre-wrap;?/*?Mozilla?*/
    28. ?whitewhite-space:?-hp-pre-wrap;?/*?HP?Printers?*/
    29. ?word-wrap:?break-word;?/*?IE?5+,?鏂囨湰琛岀殑浠繪剰瀛楀唴鏂?紑?*/
    30. }
    31. .shuoshuo-content?p{margin:0;}
    32. /*浣滆??*/
    33. .shuoshuo-meta?{
    34. text-alignrightright;
    35. letter-spacing0px;
    36. margin-top:-85px;
    37. }
    38. .toolbar{display:none}
    39. /*鏃墮棿*/
    40. /*.shuoshuo?.tt{margin:?35px?0?0?15px;float:left;font-size:0.9em;}*/
    41. /*.shuoshuo?li?em{float:left;background:url("http://www.100day.cc/wp-content/themes/frontopen2_v1.5.04.15/images/bolangxian.png")?no-repeat;width:50px;height:10px;margin:42px?0?0?28px;}*/
    42. /*.shuoshuo?li:hover?.tt?{color:#0c0;font-weight:bold;}?*/
    43. /*澶村儚*/
    44. .shuoshuo?.zhutou{border-radius:?50%;margin25px?35px?0?5px;float:rightright;padding2px;border1px?#ddd?solid;displayblock;transition:?.5s;width40px;height40px;overflow:hidden;}
    45. .shuoshuo?li:hover?.zhutou?{
    46. transform:?rotate(720deg);-webkit-transform:?rotate(720deg);-moz-transform:?rotate(720deg);border-color#0c0;}
    47. /*鍓嶉潰鐨勮醬*/
    48. .shuoshuo:before?{
    49. height:?100%;
    50. width2px;
    51. background#eee;
    52. positionabsolute;
    53. left164px;
    54. content"";
    55. top:0px;
    56. }
    57. .shuoshuo-content:before?{
    58. positionabsolute;
    59. top40px;
    60. bottombottom0px;
    61. left:?-42px;
    62. background#fff;
    63. height12px;
    64. width12px;
    65. border-radius:?6px;
    66. content"";
    67. box-shadow:?inset?0?0?2px?#0c0;
    68. }
    69. .shuoshuo-content:after?{
    70. positionabsolute;
    71. top42px;
    72. bottombottom0px;
    73. left:?-40px;
    74. background#ccc;
    75. height8px;
    76. width8px;
    77. border-radius:?6px;
    78. content"";
    79. }
    80. .shuoshuo?li:hover?.shuoshuo-content:after?{
    81. background#0c0;
    82. -webkit-transform:?scale(1.3);
    83. -moz-transform:?scale(1.3);
    84. -ms-transform:?scale(1.3);
    85. -o-transform:?scale(1.3);
    86. }
    87. .shuoshuo?li:hover?.shuoshuo-content:before?{-webkit-transform:?scale(1.3);
    88. -moz-transform:?scale(1.3);
    89. -ms-transform:?scale(1.3);
    90. -o-transform:?scale(1.3);}
    91. /*鍚庨潰鐨勮醬*/
    92. .shuoshuo:after?{
    93. height:?100%;
    94. width2px;
    95. background#eee;
    96. positionabsolute;
    97. rightright100px;
    98. content"";
    99. top:0px;
    100. }
    101. .shuoshuo-meta:before?{
    102. positionabsolute;
    103. top42px;
    104. bottombottom0px;
    105. rightright:?-56px;
    106. background#fff;
    107. height12px;
    108. width12px;
    109. border-radius:?6px;
    110. content"";
    111. z-index:2;
    112. box-shadow:?inset?0?0?2px?#0c0;
    113. }
    114. .shuoshuo-meta:after?{
    115. positionabsolute;
    116. top44px;
    117. bottombottom0px;
    118. rightright:?-54px;
    119. background#ccc;
    120. height8px;
    121. width8px;
    122. z-index:2;
    123. border-radius:?6px;
    124. content"";
    125. }
    126. .shuoshuo?li:hover?.shuoshuo-meta:after?{
    127. background#0c0;
    128. }
    129. @media?screen?and?(min-width:1080px){
    130. .shuoshuo{width:1060px;margin:50px?auto}
    131. }
    132. @media?screen?and?(max-width800px)?{
    133. .shuoshuo-content?{margin:0?60px?0?70px;padding10px?10px?5px?10px;font-size:0.9em;}
    134. .shuoshuo?.tt{width:30px;font-weight:bold;margin30px?0?0?1px;font-size:0.5em;height20px;}
    135. .shuoshuo?li:hover?.tt?{color:#0c0;font-size:0.5em;}
    136. .shuoshuo:before?{left50px;}
    137. .shuoshuo-content:before?{left:?-26px;top:30px;}
    138. .shuoshuo-content:after?{left:?-24px;top:32px;}
    139. .shuoshuo:after?{rightright27px;}
    140. .shuoshuo-meta:before?{rightright:?-39px;top:33px;}
    141. .shuoshuo-meta:after?{rightright:?-37px;top:35px;}
    142. .shuoshuo?.zhutou{margin17px?5px?0?5px;}
    143. .shuoshuo?li?em{float:left;width:39px;height:10px;margin:34px?0?0?-1px;}
    144. }

    最后,打開后臺 → 頁面 → 新建頁面,標題處輸入“我的說說”,頁面模板處選擇我們的“說說頁面”,然后直接點擊發布頁面。

    注:如果不想富媒體說說,單純地寫文字的話,可以把最后一段代碼中的<?php the_content(); ?>改成<?php the_title(); ?>,這樣以后發表說說只要填寫標題就可以了,查找起來也比較方便。如果你用<?php the_content(); ?>,那么你發表說說的時候標題和內容要寫成一樣,以方便查找,如果你只填寫內容,那么你在后臺查看說說的時候,顯示的列表全是無標題,對于修改比較麻煩。

    鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

    【本文鏈接】:http://www.nbkh.net.cn/wordpress/1016.html

    黄色电影国语完整版 - 视频 - 在线观看 - 影视资讯 - 品爱网