zoukankan      html  css  js  c++  java
  • WordPress主题制作教程9:文章形式

    wordpress的文章形式:

    aside -----------------日志:不显示标题的标准文章
    image --------------图像:单张图像。文章中的首个 <img /> 标记将会被认为是该图片。

    video ---------------视频:单一视频。

    quote -----------------引语:引用他人的一段话。

    link -----------------链接:链接到其它网站的链接。

    gallery ---------------相册:图像陈列厅。

    status --------------状态:简短更新,通常最多 140 个字符。类似于微博
    audio ----------------音频:一个音频文件
    chat ------------------聊天: 聊天记录

    如果想添加对以上形式的支持,在functions.php对应数组中增加以上列表的类型别名即可

    add_theme_support( 'post-formats', array(
    'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
    ) );

    如何将不同的类型的文章展示出不同的风格呢?整合文章样式,在single.php通过has_post_format判断文章类型来输出不同的格式:

    <?php if( has_post_format( 'status' )) { //状态 ?>
    状态样式
    <?php } else if ( has_post_format( 'aside' )) { //日志 ?>
    日志样式
    <?php } else if ( has_post_format( 'gallery' )) { //相册 ?>
    相册样式
    <?php } else if ( has_post_format( 'video' )) { //视频 ?>
    视频样式
    <?php } else if ( has_post_format( 'audio' )) { //音乐 ?>
    音乐样式
    //....
    <?php } else{ //标准 ?> 常规样式 <?php } ?>

    添加文章类型插件:Custom Post Type UI

  • 相关阅读:
    OpenCV中的绘图函数
    整理不错的opencv博客
    opencv中的函数
    这是一个学习前端技术的网站
    HDU1520 Anniversary party(树形DP入门)
    CF1255C League of Leesins(图论)
    HDU4725 The Shortest Path in Nya Graph(最短路分层)
    1288C Two Arrays
    CF1294D MEX maxiszing
    CF1295C Obtain the String
  • 原文地址:https://www.cnblogs.com/tinyphp/p/4335436.html
Copyright © 2011-2022 走看看