wordpress主题制作3 Functions.php 常见功能

开启仪表盘定制主题功能

开启 仪表盘—->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
标题标签

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值