single_cat_title()º¯Êý
single_cat_title()º¯Êý£¬ÈÕ³£ÖÐÎÒÃǺÜÉÙ»aÓõ½£¬µ«Õa¸oº¯Êý»a¸øÎÒÃǽa¾oºÜ¶aÎÊÌa£¬ÖiÈ統ǰҳÃaeµÄĿ¼¡¢±eÇ(C)£¬¸Ãº¯Êý²»ÒÀ¸½ÓÚ WordPress Ö÷Ñ»ÖУ¬Ò²²»ÄÜÅÈeÖ÷Ñ»*ÖÐʹÓá£
ÃeÊo
»ñÈ¡µ±Ç°Ò³ÃaeµÄ*ÖÀa¡¢±eÇ(C)¡£
<?php single_cat_title($prefix,$display); ?>
ʵÀý
ÔÚ´Ëժȡ WordPress 2011 ĬÈÏÖ÷ÌaÖУ¬category.php Îļþ µÚ18ÐÐ×oÓÒλÖõĴuÂe
<?php
printf( __( 'Category Archives: %s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?>
get_the_title ºÍ the_title
get_the_title ºÍ the_title Á½¸oº¯ÊýÓÃÀ´ÔÚÎÄÕÂÒ³ÃaeÏÔʾÎÄÕ±eÌaµÄº¯Êý£¬Ö®ËuÒÔ½«Á½¸oº¯ÊýºÏ²¢µ½Ò»ÆªÎÄÕÂÀiÃaeÈ¥ÊÇÒoΪÕaÁ½¸oº¯ÊÇÒ»¸oʵÏÖ£¬Ö»²»¹ý the_title ĬÈÏÖ±½ÓÏÔʾ£¬get_the_title ĬÈϵ»Ø×Öu´®£¬Èç¹uÄa¶Ô´ËÐÄ´aeÒÉ»o£¬ÄÇÇeÄaÍuÏ¿´¡£
º¯ÊýÏe½a
get_the_title ºÍ the_titleÕaÁ½¸oº¯ÊýÖ÷ÒªÓÃÓÚÔÚÑ»ÖÐÏÔʾµ±Ç°ÎÄÕµıeÌa£¬Çe×¢Òa the_title Õa¸oº¯Êý±ØÐeʹÓÃÔÚÑ»ÖС£
Á½ÕßµÄÇø±ðÔÚÓÚ£¬get_the_title½oÄÜÒÔ×Öu´®ÐÎʽµ»ØÎÄÕ±eÌa£¬¶ø the_title ¿ÉÒÔÉeÖñeÌaÇ°ºoµÄ×Ô¶¨Òa×Öu£¬ÒÔ¼°ÊÇÏÔʾ»¹Êǵ»Ø×Ö*u´®¡£
the_title º¯ÊýʹÓᢲÎÊýÏe½a
<?php the_title( $before, $after, $echo ); ?>
the_titleʾÀý
<?php the_title( ¡®=>', ¡®<=' ); ?>
ÒÔ±¾ÎÄΪÀý£¬ÎÒÃǽ«µÃµ½ÒÔÏÂÕaÑuµÄ±eÌa£º
¡®=>get_the_title ºÍ the_title<='
get_the_title º¯ÊýʹÓᢲÎÊýÏe½a
<?php $myTitle = get_the_title($ID); ?>
ÒÔÉÏ´uÂeÎÒÃǽ«µÃµ½ÎÄÕ±eÌaµÄ±aÁ¿$myTitle;
$ID ÓÃÓÚÉeÖÃÎÄÕ ID £¬µ±È»ÔÚÑ»*ÖÐÎÒÃÇ¿ÉÒÔÊ¡ÂԴ˲ÎÊý¡£
get_the_title ʾÀý
<?php
$myTitle = get_the_title($ID);
echo $mytitle.'¡¾±eÌaÑÝʾ¡¿';
?>
ÎÒÃǽ«µÃµ½
get_the_title ºÍ the_title¡¾±eÌaÑÝʾ¡¿
×ܽa
˵ÁËÕaô¶a£¬²»ÖªµÀ¶ÔÄuÊÇñÓÐËu°iÖu£¿
×ܵÄÀ´Ëµ the_title ÊÇ get_the_titleµÄ¸u¸ßÒ»¼¶a×°¡£¾ÍÏñÔÚ wp_titleÖÐ˵µÄÄÇÑu£¬¸u¸ß¼¶*a×°£¬ËaȻʹÓÃÆðÀ´¼oµ¥£¬µ«ÄÜÕÛÌÚ»¨ÑuÏa¶ÔÉÙÁ˵a¡£
ÏÂÃaeÊǸÃÁ½¸oº¯ÊýµÄÔ´´uÂe
the_title º¯ÊýÉuÃ÷
¸Ãº¯ÊýλÓÚ wp-include/post-template.php ÎļþµÄ 43 ¨C 55ÐÐ×oÓÒµÄλÖÃ
<?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 º¯ÊýÉuÃ÷
¸Ãº¯ÊýλÓÚ wp-include/post-template.php ÎļþµÄ 103 ¨C 118ÐÐ×oÓÒµÄλÖÃ
<?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 );
}
?>