100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 仿秋叶网 php源码 纯代码给WordPress添加类似说说/微语功能

仿秋叶网 php源码 纯代码给WordPress添加类似说说/微语功能

时间:2019-11-28 08:42:42

相关推荐

仿秋叶网 php源码 纯代码给WordPress添加类似说说/微语功能

WordPress说说/微语功能,简单实用。很适合发一些语录、一句话文章等。这个功能也为博客起到了一个很好的点睛的作用。

本文参照孟小N的文章:

下边代码基本主题都可以直接套用,有些主题稍微改动下代码就可以了,很简单,如果有问题可以评论问我,我都会尽力回复的。

添加说说功能

将以下代码直接加入到functions.php中。

//添加说说页面功能add_action('init', 'my_custom_init'); function my_custom_init() {

$labels = array(

'name' => '说说',

'singular_name' => '说说',

'all_items' => '所有说说',

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

添加好后,效果如下:

添加说说页面模板

新建一个PHP文件,放到主题pages文件夹中,这里直接把样式写到了代码中,不需要引用别的CSS文件了,写入代码如下:

Template Name: 说说页面

*/

get_header(); ?>

#shuoshuo_content {

background-color: #fff;

padding: 15px;

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

}

/* end */

class="article" style="">

publish&posts_per_page=-1");if (have_posts()) :

while (have_posts()) : the_post(); ?>

"/avatar/147075fce9b00cfd997a4b1

1e8df7347?s=160&r=g" class="avatar avatar-48" width="48"

height="48">

<?php get_footer();?>

然后新建页面,选择模板说说页面即可。

这个模板显示出的是说说文章内容,可以把156行的<?php the_content(); ?>替换为<?php the_title(); ?>以显示说说标题。

如果你是前端大神,说说页面模板随意修改为你自己想要的,在这里,我只是拿来当个例子。

最后新建说说,就可以在网页上看到你写的说说了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。