久久久精品2019免费观看_亚洲国产精品成人久久久_69国产成人综合久久精品91_国产精品久久精品视

wordpress網(wǎng)站增加說(shuō)說(shuō)(類似微博)功能

1.首先在后臺(tái)添加說(shuō)說(shuō)的菜單,能夠在后臺(tái)發(fā)布說(shuō)說(shuō)。

 

主要是操作所使用主題目錄的functions.php,添加如下代碼在最后面:

//說(shuō)說(shuō)

add_action(‘in

function my_custom_init()

{ $labels = array( ‘name’ => ‘說(shuō)說(shuō)’,

‘singular_name’ => ‘singularname’,

‘add_new’ => ‘發(fā)表說(shuō)說(shuō)’,

‘add_new_item’ => ‘發(fā)表說(shuō)說(shuō)’,

‘edit_item’ => ‘編輯說(shuō)說(shuō)’,

‘new_item’ => ‘新說(shuō)說(shuō)’,

‘view_item’ => ‘查看說(shuō)說(shuō)’,

‘search_items’ => ‘搜索說(shuō)說(shuō)’,

‘not_found’ => ‘暫無(wú)說(shuō)說(shuō)’,

‘not_found_in_trash’ => ‘沒(méi)有已遺棄的說(shuō)說(shuō)’,

‘parent_item_colon’ => ”,

‘menu_name’ => ‘說(shuō)說(shuō)’ );

$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); }

檢查無(wú)誤后,上傳,然后去后臺(tái),就發(fā)現(xiàn),左側(cè)的管理菜單中,就有說(shuō)說(shuō)。如上面的圖。

2.制作一個(gè)頁(yè)面模板,這個(gè)模板起名為shuoshuo.php,放在所使用的主題模板根目錄下,用于顯示后臺(tái)所發(fā)布的說(shuō)說(shuō)內(nèi)容。華哥的shuoshuo.php如下(相對(duì)于原教程代碼,有不少的改動(dòng))

<?php /*

Template Name: 說(shuō)說(shuō)

*/

get_header(); ?>

<link href=”/wp-content/themes/blogrow/shuoshuo.css” rel=”stylesheet”>

<section class=”pad group”>

<div class=”shuoshuo”>

<ul class=”archives-monthlisting”>

<?php query_posts(“post_type=shuoshuo&post_status=publish&posts_per_page=-1″);if (have_posts()) : while (have_posts()) : the_post(); ?>

<li><span class=”tt”>

<?php the_time(‘Y年n月j日G:i’); ?>

</span><br><span >—

<?php the_author() ?>

</span>

<div class=”shuoshuo-content”>

<P> <b><?php the_title(); ?></b></P>

<?php the_content(); ?>

</div>

<?php endwhile;endif; ?>

</li>

</ul>

</div>

</section>

<?php get_footer(); ?>

這個(gè)頁(yè)面模板對(duì)應(yīng)的就是:華哥的說(shuō)說(shuō) 這個(gè)樣子。

3.上面只是準(zhǔn)備好了模板,還需要?jiǎng)?chuàng)建一個(gè)頁(yè)面,來(lái)使用這個(gè)模板,在頁(yè)面中選擇新建,輸入標(biāo)題后,內(nèi)容不要填寫為空,然后重點(diǎn)操作是選擇模板為剛才所制作的“說(shuō)說(shuō)”模板。

 

上圖模板中可以選擇說(shuō)說(shuō),那這個(gè)說(shuō)說(shuō)模板名稱哪來(lái)的呢?模板是shuoshuo.php呀!那就要注意模板中第一行的注釋了,如下:

<?php /*

Template Name: 說(shuō)說(shuō)

*/

get_header(); ?>

說(shuō)說(shuō)就是從上邊來(lái)的。你可以改成任何你喜歡的名稱。

4.能不能把最新發(fā)的說(shuō)說(shuō),通過(guò)小工具,顯示在首頁(yè)或內(nèi)容頁(yè)的右側(cè)呢?目前還沒(méi)有找到方法和花費(fèi)時(shí)間去實(shí)踐。

未經(jīng)允許不得轉(zhuǎn)載:445IT之家 » wordpress網(wǎng)站增加說(shuō)說(shuō)(類似微博)功能

贊 (0) 打賞

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

微信掃一掃打賞