最新公告
  • 欢迎您光临知事网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • WordPress函数get_the_title()用法 获取指定/当前文章的标题

    描述:

    获取指定/当前文章的标题

    用法:

    <?php echo get_the_title( $ID ); ?>

    参数:

    $id

    (integer or object) (可选) 文章的ID或指定从中获取标题的文章的对象。默认情况下,将获取当前文章。

    默认值: null

    源文件:

    /**
    * Retrieve post title.
    *
    * If the post is protected and the visitor is not an admin, then "Protected"
    * will be displayed before the post title. If the post is private, then
    * "Private" will be located before the post title.
    *
    * @since 0.71
    *
    * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    * @return string
    */
    function get_the_title( $post = 0 ) {
    $post = get_post( $post );
    
    $title = isset( $post->post_title ) ? $post->post_title : '';
    $id = isset( $post->ID ) ? $post->ID : 0;
    
    if ( ! is_admin() ) {
    if ( ! empty( $post->post_password ) ) {
    
    /**
    * Filter the text prepended to the post title for protected posts.
    *
    * The filter is only applied on the front end.
    *
    * @since 2.8.0
    *
    * @param string $prepend Text displayed before the post title.
    * Default 'Protected: %s'.
    * @param WP_Post $post Current post object.
    */
    $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ), $post );
    $title = sprintf( $protected_title_format, $title );
    } elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) {
    
    /**
    * Filter the text prepended to the post title of private posts.
    *
    * The filter is only applied on the front end.
    *
    * @since 2.8.0
    *
    * @param string $prepend Text displayed before the post title.
    * Default 'Private: %s'.
    * @param WP_Post $post Current post object.
    */
    $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ), $post );
    $title = sprintf( $private_title_format, $title );
    }
    }
    
    /**
    * Filter the post title.
    *
    * @since 0.71
    *
    * @param string $title The post title.
    * @param int $id The post ID.
    */
    return apply_filters( 'the_title', $title, $id );
    }
    找互联网优质资源,上知事网!
    知事网 » WordPress函数get_the_title()用法 获取指定/当前文章的标题

    常见问题FAQ

    网盘提取密码在哪里?
    在网站右侧有个“文件密码”,点击复制即可!
    网站的积分如何获得?
    注册登录后,每天签到可获得1个积分,每天可签到一次!

    发表评论

    • 1420会员总数(位)
    • 690资源总数(个)
    • 24本周发布(个)
    • 0 今日发布(个)
    • 3467稳定运行(天)

    提供最优质的资源集合

    Mac软件 Dedecms源码
    升级SVIP尊享更多特权立即升级