日主题增加文章单栏类型

wp主题支持10种类型的文章格式,我们日主题,调用了其中四个,相册、图像、标准、视频,那么现在要单栏的,我就多加一个 日志模式(aside)
第一步:复制你主题content.php(着是标准格式)文件,把里面的 get sidebar去掉,也就是去掉了侧栏,然后原来的content距离右侧有距离,我们加一段代码把他去掉,然后重命名为 content-aside.php
第二步:把这个格式注册到主题后台,并且把 日志模式改名叫 单栏,需要到 functions-theme.php文件里注册并修改,注册

日主题增加文章单栏类型

将 content-aside.php文件保持到日主题根目录下

然后functions-theme.php文件

搜索 注册文章 四个字

替换成

/**
* 注册文章类型
*/
add_theme_support(‘post-formats’, array(‘gallery’, ‘image’, ‘video’, ‘aside’));
add_post_type_support(‘page’, ‘post-formats’);

function rename_post_formats( $safe_text ) {
if ( $safe_text == ‘日志’ ) return ‘单栏’;
return $safe_text;
}
add_filter( ‘esc_html’, ‘rename_post_formats’ );

content-aside.php 代码如下:

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

<section class=”article-focusbox bgimg-fixed” id=”focsbox-true” <?php _single_header_img() ?> >
<header class=”article-header”>
<h1 class=”article-title”><?php the_title(); ?><?php echo get_the_subtitle() ?></h1>
<div class=”article-meta”>
<span class=”item item-1″><?php echo get_the_date().’ ‘.get_the_time(); ?></span>
<span class=”item item-2″>作者:<?php echo get_the_author() ?></span>
<span class=”item item-3″><?php echo ‘分类:’;the_category(‘ / ‘); ?></span>
<span class=”item item-4″><i class=”iconfont”>&#xe681;</i> <?php echo _get_post_views() ?></span>
<span class=”item item-5″><?php edit_post_link(‘[编辑]’); ?></span>
</div>
</header>
</section>

<section class=”container”>
<div class=”content-wrap”>
<div class=”content” style=”margin-right:0 !important”>

<?php _the_ads(‘ad_post_header’, ‘single-header’) ?>

<article class=”article-content”>
<div class=”article-zhaiyao”><strong>摘要:</strong><?php echo _get_excerpt(); ?></div>
<?php the_content(); ?>

<?php wp_link_pages(‘link_before=<span>&link_after=</span>&before=<div class=”article-paging”>&after=</div>&next_or_number=number’); ?>

<?php if( _hui(‘post_copyright_s’) ){ ?>
<?php get_template_part( ‘module/content’, ‘module-copyright’ ); ?>
<?php } ?>

<?php endwhile; ?>

<?php get_template_part( ‘module/content’, ‘module-wechats’ ); ?>

<?php get_template_part( ‘module/content’, ‘module-share’ ); ?>

</article>

<?php if( _hui(‘post_prevnext_s’) ){ ?>
<nav class=”article-nav”>
<span class=”article-nav-prev”><?php previous_post_link(‘上一篇<br>%link’); ?></span>
<span class=”article-nav-next”><?php next_post_link(‘下一篇<br>%link’); ?></span>
</nav>
<?php } ?>

<?php _the_ads(‘ad_post_footer’, ‘single-footer’) ?>

<?php if( _hui(‘post_related_s’) ){ ?>
<div class=”postitems”>
<h3><?php echo _hui(‘related_title’, ‘相关推荐’) ?></h3>
<ul>
<?php _posts_related( _hui(‘post_related_n’) ) ?>
</ul>
</div>
<?php } ?>

<?php _the_ads(‘ad_post_comment’, ‘single-comment’) ?>
<?php comments_template(”, true); ?>

</div>
</div>

</section>

1、若侵权,请提供相关必要证明,否则不予回复!
2、若无特殊注明,本文皆为作者原创,商业转载请联系作者授权,非商业转载请注明出处。
3、本站所发布的资源仅用于交流、学习!商业源码若无授权请勿使用,违者所造成的后果与本站无关!

雄企科技 » 日主题增加文章单栏类型

分享到:
赞(0) 打赏

评论抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏