最新公告
  • 欢迎光临爱下载,本站专业为站长提供各种资源。立即加入我们
  •  

    1、在子主题functions.php中加入代码:

    ps:子主题真的是个好东西,每次更新都不用在去改风格,调整子主题兼容就好了

    //新建快讯功能 
    add_action('init', 'my_custom_init');
    function my_custom_init() {
    	$labels = array( 'name' => '快讯',
    	'singular_name' => '快讯',
    	'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,
    	'exclude_from_search' =>true,
    	'query_var' => true,
    	'rewrite' => true, 'capability_type' => 'post',
    	'has_archive' => false, 'hierarchical' => false,
    	'menu_position' => null, 'supports' => array('editor','author','title', 'custom-fields') );
    	register_post_type('kuaixun',$args);
    }
    

     

    加上代码后,刷新后台,导航就会出现快讯的发布

    2、在子主题目录/pages下创建kuaixun.php,添加代码

    <?php /*
        Template Name: 快讯页面
        author: x22t.com
        url: https://xiazai.x22t.com/
        */
        get_header(); ?>
    <style type="text/css">
        #shuoshuo_content {
            background-color: #fff;
            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);
        }
        /* end */
    </style>
    </head>
    <body>
    <div id="primary" class="content-area" style="">
        <main id="main" class="site-main" role="main">
            <div id="shuoshuo_content">
                <ul class="cbp_tmtimeline">
                    <?php query_posts("post_type=kuaixun&post_status=publish&posts_per_page=-1");if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <li> <span class="shuoshuo_author_img"><img src="/kuaixun.jpg" class="avatar avatar-48" width="48" height="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>
        </main>
        <!-- .site-main -->
    </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_sidebar(); ?>
    <?php get_footer();?>
    

     

    然后,吧前端调整为自己喜欢的,就ok了

    搞定之后在`页面` 选项卡新建一个页面,把模板设置为快讯页面,保存后进入到此页面就会显示所有的快讯了。

    1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服![email protected]
    2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
    3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
    4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有站币奖励和额外收入!

    爱下载 » WordPress Ripro子主题美化 – 添加快讯功能

    发表评论

    • 193会员总数(位)
    • 9286资源总数(个)
    • 0本周发布(个)
    • 0 今日发布(个)
    • 962稳定运行(天)

    专业服务中小型站长,提供定制、设计、开发三位一体服务

    开通会员 了解详情