WordPress开发中用于标题显示的相关函数使用解析
《:WordPress开发中用于标题显示的相关函数使用解析》要点: single_cat_title()函数 描写 <?php single_cat_title($prefix,$display); ?>
实例 <?php printf( __( 'Category Archives: %s','twentyeleven' ),'<span>' . single_cat_title( '',false ) . '</span>' ); ?> get_the_title 和 the_title 函数详解 the_title 函数使用、参数详解 <?php the_title( $before,$after,$echo ); ?>
the_title示例PHP实例 <?php the_title( ‘=>',‘<=' ); ?> 以本文为例,我们将得到以下这样的题目:PHP实例 ‘=>get_the_title 和 the_title<=' get_the_title 函数使用、参数详解 <?php $myTitle = get_the_title($ID); ?> 以上代码我们将得到文章题目的变量$myTitle; get_the_title 示例 <?php $myTitle = get_the_title($ID); echo $mytitle.'【题目演示】'; ?> 我们将得到PHP实例 get_the_title 和 the_title【题目演示】PHP实例 总结 the_title 函数声明 <?php /** * Display or retrieve the current post title with optional content. * * @since 0.71 * * @param string $before Optional. Content to prepend to the title. * @param string $after Optional. Content to append to the title. * @param bool $echo Optional,default to true.Whether to display or return. * @return null|string Null on no title. String if $echo parameter is false. */ function the_title($before = '',$after = '',$echo = true) { $title = get_the_title(); if ( strlen($title) == 0 ) return; $title = $before . $title . $after; if ( $echo ) echo $title; else return $title; } ?> get_the_title 函数声明 <必修php /** * 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 $id Optional. Post ID. * @return string */ function get_the_title( $id = 0 ) { $post = &get_post($id); $title = isset($post->post_title) 必修 $post->post_title : ''; $id = isset($post->ID) 必修 $post->ID : (int) $id; if ( !is_admin() ) { if ( !empty($post->post_password) ) { $protected_title_format = apply_filters('protected_title_format',__('Protected: %s')); $title = sprintf($protected_title_format,$title); } else if ( isset($post->post_status) && 'private' == $post->post_status ) { $private_title_format = apply_filters('private_title_format',__('Private: %s')); $title = sprintf($private_title_format,$title); } } return apply_filters( 'the_title',$title,$id ); } 必修> 编程之家培训学院每天发布《:WordPress开发中用于标题显示的相关函数使用解析》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |