如何为wordpress创建一个说说页面

如何为wordpress创建一个说说页面,先看演示
http://ifcam.net/shuoshuo.html

实现方法

1、建立页面
新建shuoshuo.php,添加如下代码

<?php
/*Template Name: 说说*/
?>
<?php get_header(); ?>
<div class="page-page">
<div class="page-title wow fadeInDown" data-wow-delay="0.1s" style="background-color:#384047;">
<div class="container">
<h1 style="text-align:center;"><?php the_title();?></h1>
</div>
</div>
</div>
<div class="row"></div>
<div class="container">
<?php get_sidebar(); ?>
<div class="mainleft wow fadeInUp" data-wow-delay="0.1s" id="content">
<div class="article_container row box">
<div id="shuoshuo_content">
<ul class="cbp_tmtimeline">
<?php query_posts("post_type=shuoshuo&post_status=publish&posts_per_page=-1");if (have_posts()) : while (have_posts()) : the_post(); ?>
<li> <span class="shuoshuo_author_img"><?php echo get_avatar(get_the_author_email(),48);?></span>
<a class="cbp_tmlabel" href="javascript:void(0)">
<p></p>
<p><?php the_content(); ?></p>
<p></p>
<p class="shuoshuo_time"><i class="fa fa-clock-o"></i>
<?php the_time('Y年n月j日G:i'); ?>
</p>
</a>
<?php endwhile;endif; ?>
</li>
</ul>
</div>
</div>
<div id="comments_box">
<?php comments_template(); ?>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
var oldClass = "";
var Obj = "";
$(".cbp_tmtimeline li").hover(function () {
Obj = $(this).children(".shuoshuo_author_img");
Obj = Obj.children("img");
oldClass = Obj.attr("class");
var newClass = oldClass + " zhuan";
Obj.attr("class", newClass);
}, function () {
Obj.attr("class", oldClass);
})
})
</script>
<?php get_footer(); ?>

2、修改function函数
打开主题functions.php文件,在最下方添加函数

//说说
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); }

 

3、添加css样式
打开主题style.css(或者自定义个css)添加如下代码

/*说说*/
#shuoshuo_content { background-color: #fff; padding: 10px; min-height: 500px;}
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; }
.cbp_tmtimeline:before { content: ''; position: absolute; top: 0; bottom: 0; width: 4px; background: RGBA(0, 0, 0, 0.02); left: 80px; margin-left: 10px;}
.cbp_tmtimeline > li .cbp_tmtime {display: block; 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;}
.cbp_tmtimeline > li .cbp_tmlabel {margin: 0 0 45px 65px;background: #9BCD9B;color: #fff;padding: .8em 1.2em .4em 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: 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);}
.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 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);}

 

免责声明:
1. 本站所有资源来源于网络,仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请自负。
2. 如果您喜欢该源码,请支持购买正版,得到更好的正版服务。
3. 如果你有好源码或者教程,可以联系站长投稿,分享有金币奖励和额的外收入!
4. 本站提供的非本站原创资源都不包含技术服务请大家谅解!
5. 如有链接无法下载或失效,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站无法保证所有资源的准确性、安全性和完整性!
8. 如本站源码有侵权问题,请联系站长!