开启仪表盘定制主题功能
开启 仪表盘—->apperance—->themes—->customize编辑定制主题 功能
在functions.php文件加代码:
<?php
//……
//主题定制功能
function add_theme_customizer( $wp_customize )
{
}
add_action( 'customize_register', ' add_theme_customizer');
?>
特色图片
网站文章编辑右侧添加特色图片模块功能。首先需要添加图片功能,在function.php文件中添加:
add_theme_support( 'post-thumbnails' );
然后index.php文件中,在循环中添加代码:
<div class="entrycontent">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail('large');
} ?>
</div>
文章发布格式 文章形式
允许用户以不同方式发布文章,如标准、图片、视频、引用、图组、声音等形式。
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio', 'quote') );
);
显示作者,时间
<p class="entry-meta">
by <?php the_author();?>//the_author();显示作者函数
in <?php the_time();?>//the_time();显示作者函数
</p>
显示评论数量
<a href='<?php the_permalink() ?>'>//the_permalink();显示评论跳转链接
<?php comments_number('0', '1', '%') ?>//comments_number(‘0’, ‘1’, ‘%’);显示评论数量
</a>
加载文本域
主题可以通过通过使主题中的字符串翻译成多种语言,需要使用 load_theme_textdomain()。
指明主题的语言目录位于主题的 languages 文件夹
<?php load_theme_textdomain( $domain, $path ) ?>
其他功能
还有其他常见功能包含在functions.php中。如以下最常见的功能:
自定义标题
侧栏
自定义背景、
添加编辑器样式
HTML5
标题标签
网友评论